Update query in ado.net
- by nikhil
I wanted to update a column in my table, i have written the code it runs fine without any error also it displays the confirmation dialog box but the table is not updated whats wrong with the code.
Dim sqlConn As New SqlClient.SqlConnection
sqlConn.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\housingsociety.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
Try
sqlConn.Open()
Catch sqlError As Exception
MsgBox(sqlError.Message, 0, "Connection Error!")
End Try
Dim sqlComm As New SqlClient.SqlCommand
sqlComm.Connection = sqlConn
sqlComm.CommandText = "update committe_member set name = '@name' where name = 'member1'"
Dim paramString As New SqlClient.SqlParameter("@name", SqlDbType.VarChar, 50)
paramString.Direction = ParameterDirection.Input
sqlComm.Parameters.Add(paramString)
paramString.Value = TextBox1.Text
sqlComm.ExecuteNonQuery()
MsgBox("Record Sucessfully Altered", 0, "Confirmation!")
sqlConn.Close()