Update query in ado.net

Posted by nikhil on Stack Overflow See other posts from Stack Overflow or by nikhil
Published on 2011-01-15T15:48:24Z Indexed on 2011/01/15 15:53 UTC
Read the original article Hit count: 162

Filed under:
|

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()

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about ADO.NET