My SQl error while sending to database
-
Hi string conn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; MySqlConnection con = new MySqlConnection(conn); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = con; cmd.CommandText = "Insert_Image"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("?description", SqlDbType.VarChar).Value = txtdesc.Text; cmd.Parameters.AddWithValue("?fullstr", SqlDbType.VarChar).Value = path; con.Open(); cmd.ExecuteNonQuery(); cmd.Connection.Close(); Session.RemoveAll(); My code is giving error at executenonquery, "Input string not in correct format". The values in path and txt dec are correct. Can you please tell where i am wrong? Regards Inderjeet Kaur Inderjeet Kaur Sr. Software Engg
-
Hi string conn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; MySqlConnection con = new MySqlConnection(conn); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = con; cmd.CommandText = "Insert_Image"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("?description", SqlDbType.VarChar).Value = txtdesc.Text; cmd.Parameters.AddWithValue("?fullstr", SqlDbType.VarChar).Value = path; con.Open(); cmd.ExecuteNonQuery(); cmd.Connection.Close(); Session.RemoveAll(); My code is giving error at executenonquery, "Input string not in correct format". The values in path and txt dec are correct. Can you please tell where i am wrong? Regards Inderjeet Kaur Inderjeet Kaur Sr. Software Engg
-
The AddWithValue method expects the actual value to be passed rather than the data types, so you should write something like:
cmd.Parameters.AddWithValue("?description", txtdesc.Text);
Thanks alot! I am new to MY SQL database and my problem is solved. Inderjeet Kaur Sr. Software Engg
-
Thanks alot! I am new to MY SQL database and my problem is solved. Inderjeet Kaur Sr. Software Engg
-
Hi string conn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; MySqlConnection con = new MySqlConnection(conn); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = con; cmd.CommandText = "Insert_Image"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("?description", SqlDbType.VarChar).Value = txtdesc.Text; cmd.Parameters.AddWithValue("?fullstr", SqlDbType.VarChar).Value = path; con.Open(); cmd.ExecuteNonQuery(); cmd.Connection.Close(); Session.RemoveAll(); My code is giving error at executenonquery, "Input string not in correct format". The values in path and txt dec are correct. Can you please tell where i am wrong? Regards Inderjeet Kaur Inderjeet Kaur Sr. Software Engg
When I use MySQL I use an at (@), not a question mark (?) -- I thought that was the problem, does it work with the question mark?
-
When I use MySQL I use an at (@), not a question mark (?) -- I thought that was the problem, does it work with the question mark?