I have a string that I need to convert to int before updating it in my database, but haven't managed to figure out how it's done. Here's my latest try:
int iLager = Int32.Parse(TextBoxProdNumberOf.Text);
SqlConnection conn = new SqlConnection(config);
conn.Open();
string sql = "UPDATE Produkter SET iLager ='" + iLager + "' WHERE ID ='" + ID + "'";
SqlCommand comm = new SqlCommand(sql, conn);
comm.ExecuteNonQuery();//Conversion failed when converting the varchar value '__Page' to data type int.
I've also tried:
string iLager = Convert.ToInt32(TextBoxProdNumberOf.Text);
string iLager = int.Parse(TextBoxProdNumberOf.Text);
Any ideas? Thanks in advance!