473,323 Members | 1,551 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

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

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
2 2252
Rabbit
12,516 Expert Mod 8TB
It would help to see the entire error message.
Apr 11 '12 #2
Marknut
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

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

Similar topics

0
by: Chris Hall | last post by:
The records in my database are displayed in a form as follows: %> <form action="report-ammend1.42.asp" method="post"name="form"> <table border=1> <% x = 1
7
by: Jim Geissman | last post by:
Take a table, where not all the columns are populated: CREATE TABLE #T (A int, B int, C int, D int) INSERT #T (A,B) VALUES (1,2) INSERT #T (A,B) VALUES (3,4) INSERT #T (A,B) VALUES (5,6)...
3
by: Bill Clark | last post by:
I have about 20,000 records pulled from Excel that I need to update. What I need to do is run an update query that bascially says: If a field is null, update it with the previous record value of...
4
by: Jim Hammond | last post by:
It would be udeful to be able to get the current on-screen values from a FormView that is databound to an ObjectDataSource by using a callback instead of a postback. For example: public void...
0
by: Metal2You | last post by:
I'm working on an ASP.NET 2.0 application in Visual Studio 2005 that accesses a Sybase database back end. We're using Sybase SQL Anywhere 9.0.2.3228. I have installed and registered the Sybase...
5
by: cover | last post by:
I have an input form that passes data when submitted to a second form to let the user know what they have just entered into the db. My question comes with using 'update'. I'd like to query the...
2
by: mokazawa1 | last post by:
Hi, I'm using stored procedures in DB2 UDB 8.1.2. In this stored, I execute a select for update command, opening a cursor. Then I update the rows using fetch and current of. The problem is that...
1
by: Steve Kershaw | last post by:
Hi, I have a problem in which I'm using a GridView with an ObjectDataSource as a data source. The problem is that when I use the ObjectDataSource UPDATE routine I must have the key column...
5
by: yuva17raj | last post by:
hi i am trying to update my sql table data with the csv/excel file data my sql table is as follows test test1 23 usd 25 ero 34 test and my csv file has
1
by: tekedge | last post by:
Hi, I have to do an update using a query which uses CTE . Could any body please tell me how I can do an update. I am unable to update if I replace the final select with an update one. Thanks...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.