VB Failed To Update SQL Using Update ... SET....WHERE

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kezn
    New Member
    • Apr 2012
    • 1

    VB Failed To Update SQL Using Update ... SET....WHERE

    Hi ... i tryin to update my SQL using this method but it didn't update...Anyone have a better way to do this ?

    ------------------------------------------------------------
    Code:
    Case "OUT"
    
                    Dim connectionstring As String = "Server=PENW3GFSB2S\SQLEXPRESS;Database=People;Trusted_Connection = yes"
                    Dim query As String = "Update [Names] Set [TimeOut]= '" & lblTimeNow.Text & "'where [BatchNo] ='" & Label1.Text & " ' "
                    Dim conn As New SqlConnection(connectionstring)
                    Dim cmd As New SqlCommand(query, conn)
    
    
           
    
                    conn.Open()
                    cmd.ExecuteNonQuery()
                    conn.Close()
    
                    MessageBox.Show("THX !!!")
                    txtBadgeNumber.Text = ""
    
    
                Case Else
                    Return False
            End Select
        End Function
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    It would help to see the entire error message.

    Comment

    • Marknut
      New Member
      • Apr 2010
      • 42

      #3
      It's been a while since I've done anything in ASP.NET, so my terminology might not be 100%. I would recommend creating a Data Access Layer: http://www.asp.net/web-forms/tutoria...ccess-layer-vb. Basically, you create a dataset, which holds all of your SQL statements, and run your SQL by calling the methods in the tableadapters you created within the dataset. It's really just a UI for creating and storing your SQL statements that you can call from code. You can include variables in your statements too.

      Comment

      Working...