I'm trying to avoid populating a table and using multiple queries and statements to select a specific ID representing a Holiday from a DataGridView.
Is what I'm trying to do even possible?
The code I've got so far is as follows :
string HolidayIDQuery = "SELECT ID FROM [Holiday] WHERE PayrollNo=@PayrollNo + StartDate=@StartDate + EndDate=@EndDate";
OleDbCommand GetHolID = new OleDbCommand(HolidayIDQuery, conn);
GetHolID.Parameters.AddWithValue("@PayrollNo", GotPayroll);
GetHolID.Parameters.AddWithValue("@StartDate", OleDbType.Date).Value = Convert.ToDateTime(dataGridView1.Rows[LineIndex].Cells[1].Value);
GetHolID.Parameters.AddWithValue("@EndDate", OleDbType.Date).Value = Convert.ToDateTime(dataGridView1.Rows[LineIndex].Cells[2].Value);
int HolID = Convert.ToInt32(GetHolID.ExecuteScalar());
I get this Error on the bottom line.
Exception thrown: 'System.Data.OleDb.OleDbException' in System.Data.dll
Additional information: Data type mismatch in criteria expression.
andinstead of+!+is not the same asAND