|
-
Aug 12th, 2009, 03:15 PM
#1
Thread Starter
Junior Member
[RESOLVED] SQL Datagrid updating
Ok im using a vb form with a datagrid loaded into it
The datagrid loads a button, Firstname, and time into it. What i want to do is when i hit the button on that row i want the new time to update a row with the new information. This is the code i have so far. It runs through but nothing gets updated. I think my problem is that its not on the right row or it does not know where it is. I tried finding help on this but everything ive read people use this in aspx but i want to use it in an actual vb form.
Private Sub dvg1_signout(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dvg1.CellContentClick
Dim datetime As Date
datetime = Now()
Dim connection As New SqlClient.SqlConnection(connection string)
connection.Open()
Dim update As New SqlClient.SqlCommand("UPDATE dbo.guestlog SET outdatetime = @outdatetime WHERE firstname = @firstname AND outdatetime is NULL", connection)
update.Connection = connection
update.Parameters.AddWithValue("@outdatetime", datetime)
update.Parameters.AddWithValue("@firstname", "firstname")
update.ExecuteNonQuery()
connection.Close()
Close()
End Sub
*edit*
using SQL Server 2005
VB 2005
Also no error messages
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|