Sorry to be a pain, I've checked and I have @Expiry_date and @Email_address, I can't find the spelling mistakes in the new version of my code, please help.
error insert into
Collapse
X
-
i don't know it could be run well or not. why don't you try just like i did.
i add the braket among the date field. like this :
wish it could be help.Code:insert into Intranet.classifieds_adverts (Title, [Expiry_date], Description, Added_by, Email_address) values (@Title, @Expiry_date, @Description, @Added_by, @Email_address)
coz my problem solve by that.Comment
-
if txtTitle, txtDescr,txtNam e,txtEmail are text fields then use likethanks maliksleo, i have correct the typo and it now looks like(below) this but I'm still getting the error, not sure what am I doing wrong.
Code:private void Submit_Click(object sender, System.EventArgs e) { SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]); SqlCommand cmd = new SqlCommand("Add_advert", con); cmd.CommandType = CommandType.StoredProcedure; con.Open(); cmd.Parameters.Add("@Title",SqlDbType.VarChar); cmd.Parameters["@Title"].Value = txtTitle; cmd.Parameters.Add("@Expiry_date",SqlDbType.DateTime); cmd.Parameters["@Expiry_date"].Value = txtExpiryDATE; cmd.Parameters.Add("@Description",SqlDbType.Text ); cmd.Parameters["@Description"].Value = txtDescr; cmd.Parameters.Add("@Added_by",SqlDbType.VarChar ); cmd.Parameters["@Added_by"].Value = txtName; cmd.Parameters.Add("@Email_address",SqlDbType.VarChar ); cmd.Parameters["@Email_address"].Value = txtEmail; cmd.ExecuteNonQuery(); con.Close(); }Code:cmd.Parameters["@Email_address"].Value = txtEmail.Text;
Comment
Comment