By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,327 Members | 849 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,327 IT Pros & Developers. It's quick & easy.

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

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

------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. Case "OUT"
  2.  
  3.                 Dim connectionstring As String = "Server=PENW3GFSB2S\SQLEXPRESS;Database=People;Trusted_Connection = yes"
  4.                 Dim query As String = "Update [Names] Set [TimeOut]= '" & lblTimeNow.Text & "'where [BatchNo] ='" & Label1.Text & " ' "
  5.                 Dim conn As New SqlConnection(connectionstring)
  6.                 Dim cmd As New SqlCommand(query, conn)
  7.  
  8.  
  9.  
  10.  
  11.                 conn.Open()
  12.                 cmd.ExecuteNonQuery()
  13.                 conn.Close()
  14.  
  15.                 MessageBox.Show("THX !!!")
  16.                 txtBadgeNumber.Text = ""
  17.  
  18.  
  19.             Case Else
  20.                 Return False
  21.         End Select
  22.     End Function
  23.  
  24.  
Apr 11 '12 #1
Share this Question
Share on Google+
2 Replies


Rabbit
Expert Mod 10K+
P: 12,382
It would help to see the entire error message.
Apr 11 '12 #2

P: 42
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.
Apr 11 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.