Results 1 to 6 of 6

Thread: a problem in sql update via .net

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2010
    Location
    Srilanka
    Posts
    8

    a problem in sql update via .net

    hi. now im currently developing an application as my semester project and i strucked becuse of an small error. i have tried to update a record set in the sql server 2005 databse table by giving the following code. but its not showing any errors its working and displaying a message succeeded. but in database table i cant find any changes. pls help me........

    my advance thanks for those who viewing my thread.
    sql Code:
    1. Public Shared ReadOnly SQLConnectionString As String = "Server=RUSHAN\SQLEXPRESS;Database=nolimit;Trusted_Connection=True;"
    2.    
    3. Dim cnn As SqlClient.SqlConnection
    4. Dim cmd As SqlClient.SqlCommand
    5. Dim bc As SqlClient.SqlDataAdapter
    6. Dim dr As SqlClient.SqlDataReader
    7.  
    8. Private Sub cus_mod_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cus_mod_btn.Click
    9.         Dim sql2 As String = "UPDATE customer SET name='" & cus_mod_nme.Text & "', address='" & cus_mod_add.Text & "' ,contact='" & cus_mod_con.Text & "' WHERE (id='" & cus_mod_id.SelectedIndex & "') "
    10.         cnn = New SqlClient.SqlConnection(SQLConnectionString)
    11.  
    12.         'cnn = New SqlClient.SqlConnection(SQLConnectionString)
    13.         cnn.Open()
    14.  
    15.         cmd = New SqlClient.SqlCommand(sql2, cnn)
    16.  
    17.         cmd.ExecuteNonQuery()
    18.         MsgBox("Records affected")
    19.         cnn.Close()
    20.     End Sub
    Last edited by Hack; Jul 20th, 2010 at 07:54 AM. Reason: Added Highlight Tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width