Data type mismatch in criteria expression

  • Thread starter Thread starter Jeff0803
  • Start date Start date
J

Jeff0803

Guest
I'm trying to insert data but following error occur.

Data type mismatch in criteria expression
Code is like following.
using (OleDbConnection conn_CDMMU = new OleDbConnection(ConnectionString_CDMMU))
{
conn_CDMMU.Open();
queryString = "INSERT INTO patient ([patient_id],[title],[first_name],[last_name]" +
",[h_phone],[w_phone],[birth_date],[address1],[city],[state],[zip],[sex],[ssnumber]" +
",[medical_alert],[driver_license],[patient_type],[primary_provider]" +
",[status],[mi_name],[alt_chart_no],[cell_phone]) " +
"VALUES (@patient_id_value,@title_value,@first_name_time_value,@last_name_value" +
",@h_phone_value,@w_phone_value,@birth_date_value,@address1_value" +
",@city_value,@state_value,@zip_value,@sex_value" +
",@ssnumber_value,@medical_alert_value,@driver_license_value" +
",@patient_type_value,@primary_provider_value,@status_value" +
",@mi_name_value,@alt_chart_no_value,@cell_phone_value)";
try
{
OleDbCommand insertcommand = new OleDbCommand(queryString, conn_CDMMU);
insertcommand.CommandType = CommandType.Text;
insertcommand.Parameters.AddWithValue("@patient_id_value", patient.PatientID.ToString());
insertcommand.Parameters.AddWithValue("@title_value", patient.Title);
insertcommand.Parameters.AddWithValue("@first_name_time_value", patient.FirstName);
insertcommand.Parameters.AddWithValue("@last_name_value", patient.LastName);
insertcommand.Parameters.AddWithValue("@h_phone_value", patient.HomePhone);
insertcommand.Parameters.AddWithValue("@w_phone_value", patient.WorkPhone);
insertcommand.Parameters.AddWithValue("@birth_date_value", patient.BirthDate);
insertcommand.Parameters.AddWithValue("@address1_value", patient.Address1);
insertcommand.Parameters.AddWithValue("@city_value", patient.City);
insertcommand.Parameters.AddWithValue("@state_value", patient.State);
insertcommand.Parameters.AddWithValue("@zip_value", patient.Zip);
insertcommand.Parameters.AddWithValue("@sex_value", patient.Sex);
insertcommand.Parameters.AddWithValue("@ssnumber_value", patient.SocSec);
insertcommand.Parameters.AddWithValue("@medical_alert_value", patient.MedicalAlert);
insertcommand.Parameters.AddWithValue("@driver_license_value", patient.DriverLicense);
insertcommand.Parameters.AddWithValue("@patient_type_value", patient.PatientType);
insertcommand.Parameters.AddWithValue("@primary_provider_value", patient.PrimaryProvider.ToString());
insertcommand.Parameters.AddWithValue("@status_value", patient.Status);
insertcommand.Parameters.AddWithValue("@mi_name_value", patient.MIName);
insertcommand.Parameters.AddWithValue("@alt_chart_no_value", patient.AltChartNo);
insertcommand.Parameters.AddWithValue("@cell_phone_value", patient.CellPhone);
insertcommand.ExecuteNonQuery();
insertcommand.Dispose();

}
catch (Exception e)
{
WriteLog("InsertPatientInfo() failed. " + e.Message);
}
conn_CDMMU.Close();
}
Can anybody give me some advice?

Continue reading...
 
Back
Top