I'm trying to send a string and a bool from one form to another. The string I'm trying to send is the PayrollNo where the name is present also in the ODeDb Database.
Here's the code I'm using but its not working,
private void BtnContinue_Click(object sender, EventArgs e)
{
string ConnString = @"Provider = Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\\HoliPlanData.accdb;Persist Security Info=False";
string Query = "SELECT PayrollNo, FirstName, LastName FROM [Employee] WHERE (FirstName + ' ' + LastName) =" +DropBoxEmp.Text;
EmployeeDetails form = new EmployeeDetails();
using (OleDbConnection Conn = new OleDbConnection(ConnString))
{
Conn.Open();
OleDbCommand GetPayRoll = new OleDbCommand(Query, Conn);
string NewPayroll = (GetPayRoll.ExecuteNonQuery()).ToString();
Conn.Close();
form.PassValuePayrollNo = NewPayroll;
form.PassEditing = true;
form.Tag = this;
form.Show(this);
Hide();
}
}
I get the error :
Exception thrown: 'System.Data.OleDb.OleDbException' in System.Data.dll
Additional information: Syntax error (missing operator) in query expression '(FirstName + ' ' + LastName) =Gary Lindsay'.
DropBoxEMP is a comboBox populated with the first and last names appended from [Employee]. Gary Lindsay is the appended firstName and lastName from the Table [Employee] How should I change my code to send the string correctly? Any help would be greatly appreciated