filedname datatype(in ms access database)
Days number
course Code text
session1 yes/no
ession2 yes/no
session3 yes/no
session4 yes/no
My code as follows;
save button code as follows;
for(int i =0;i
for(int j =0;j
if(Convert.ToBoolean(DGv_Session.Rows[i].Cells[j].Value) == true)
{
sql = "insert into Tb_Session_Structure ([Cmn_Minor_code],[Days],[Session1],[Session2],[Session3],[Session4])";
sql = sql + " values ('" + cb_Course_Code.Text + "','" + DGv_Session.Rows[i].Cells[0].Value.ToString() + "','" + DGv_Session.Rows[i].Cells[1].Value.ToString() + "','" + DGv_Session.Rows[i].Cells[2].Value.ToString() + "','" + DGv_Session.Rows[i].Cells[3].Value.ToString() + "','" + DGv_Session.Rows[i].Cells[4].Value.ToString() + "')";
GFun.Error = "";
GFun.InsertAccessData(sql);
if (GFun.Error.ToString() != "")
{
MessageBox.Show(GFun.Error.ToString(), "Error");
return;
}
MessageBox.Show("Record Inserted Successfully");
}
}
}
when i rum my code and after entering the data into the datagridview and click the save button,
error shows as
Datatype mis match in crieteria expression
Vishal GilbilePosted Mar 11, 2013, 11:29 AM
From my point of view what i can see that your first column i.e. Course_Code accepts value as a number and when you are passing the value you are passing it as a string (cb_Course_Code.Text). Try to convert it as a number by using Convert class.
For eg Convert.ToInt32(cb_Course_Code.Text).
Hope that solves your problem.
With Regards,
Vishal Gilbile.