I have looked all over and I can not figure this out. I am setting up a form that will allow someone to update a product group category in the database. I want them highlight the item in the listbox and then press a remove button. I can not figure out why this will not work. I have posted the code of the sub below. The code runs fine as long as I dont reference the listbox.
Any help would be appreciated.
Code://We need to mark the selected item as inactive string cmdStr; string connStr; cmdStr = "UPDATE productGroup " + "SET active = 0 " + "WHERE Name = '" + lstMain.SelectedItem.Text + "'"; connStr = System.Configuration.ConfigurationSettings.AppSettings["connSql"]; // Create connection object SqlConnection conn = new SqlConnection(connStr); // Create command object SqlCommand cmd = new SqlCommand(cmdStr, conn); try { conn.Open(); cmd.ExecuteNonQuery(); } catch ( Exception ex ) { Response.Write(ex.Message); } finally { conn.Close(); }




Reply With Quote