Here is my code if anyone can help me please. I have created a booking ASP.NET Web Application 4.5 and are having problems on the admin page where the admin user can create a manual booking. Below are two errors i am having.
1: Conversion failed when converting the nvarchar value 'Full' to data type int.
2:Cannot convert char value to smallmoney. The char value has incorrect syntax.
here is my code where it is failling.
protected void Button1_Click1(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("INSERT INTO Job( Date, Start_Time, Valet_ID, Additions, Car_Reg, Worker_ID, Comments, Cust_ID) Values(@Date, @Start_Time, @Valet_ID, @Additions, @Car_Reg, @Worker_ID, @Comments, @Cust_ID)", con);
cmd.Parameters.AddWithValue("@Date", SqlDbType.Date).Value = txtDate.Text;
cmd.Parameters.AddWithValue("@Start_Time", SqlDbType.Time).Value = DropTime.Text;
cmd.Parameters.AddWithValue("@Valet_ID", txtValetType.Text);
cmd.Parameters.AddWithValue("@Additions", txtAdditions.Text);
cmd.Parameters.AddWithValue("@Car_Reg", txtCarReg.Text);
cmd.Parameters.AddWithValue("@Worker_ID", txtWorker_ID.Text);
cmd.Parameters.AddWithValue("@Comments", txtComments.Text);
cmd.Parameters.AddWithValue("@Cust_ID", txtCust_ID.Text);
txtDate.Text = Convert.ToString(Calendar1.SelectedDate);
txtDate.Text = Calendar1.SelectedDate.ToShortDateString();
DropTime.SelectedValue = Convert.ToString(DropTime);
txtValetType.Text = Convert.ToString(txtValetType);
cmd.ExecuteNonQuery();
con.Close();
}
Kind Regards
Neville
What I have tried:
have tried examples on-line to convert the date and time to a string. I pick a date from the calendar and it populates a text box with the selected date. The time is populated by Times that I have manually entered using collection, and is selected according to the customers required time. The times are from 0800hrs to 1930hrs. The times are split avery half an hour, for example 0800 -0830-0900-0930 and so on, and the last one stipulates that a express Valet is only available, for example 19:30 Express Only. I am not sure if the string Express Only is causing any issues but I cant see any at the moment.
If anyone could look at my code and help me with the errors I am having , I would be most grateful.