Author |
Topic |
SherryT
Starting Member
6 Posts |
Posted - 2006-11-01 : 10:59:07
|
Hi ,I am very new to this. I need help updating a table. Here is what I am doing. I have a table("TransferRequest") that has some records and Date_Transferred field.. Every 10 mins I need to check a view("v_UnTransferred") that checks the untransferred requests from the table and transfer them.After this process, the Date_Transferred field in the table needs to be updated with the time it was transferred. Here is my code: Dim rsSched As New ADODB.Recordset Dim cmd As New ADODB.Command rsSched.CursorLocation = adUseClient rsSched.CursorType = adOpenForwardOnly rsSched.LockType = adLockReadOnly rsSched.ActiveConnection = Tconn rsSched.Source = "SELECT * FROM v_UnTransferred" rsSched.Open rsSched.ActiveConnection = Nothing '''''''The transfer code is here. cmd.CommandText = "UPDATE TransferRequest SET Date_Transferred = CONVERT(datetime, '" & Now & "', 102)WHERE Date_Transferred IS Null"cmd.Execute rsSched.Close Set rsSched = NothingWhat am I doing wrong?Thanks for your helpSherry |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2006-11-01 : 11:01:59
|
do this with the scheduled job.If you want to do this in code you'll have to keep the application running constantly with the timer.Go with the flow & have fun! Else fight the flow blog thingie: http://weblogs.sqlteam.com/mladenp |
|
|
SherryT
Starting Member
6 Posts |
Posted - 2006-11-01 : 11:08:15
|
Thanks spirit1 for your reply. I am using timer to do this. But I am getting error while updating the table. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-11-01 : 11:21:40
|
[code]cmd.CommandText = "UPDATE TransferRequest SET Date_Transferred = getdate() WHERE Date_Transferred IS Null"[/code]isn't this easier ? KH |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2006-11-01 : 11:24:19
|
well that depends on which time you want to have.SQL server's time or web servers time. this can be a difference if they're in differnet timezones.Go with the flow & have fun! Else fight the flow blog thingie: http://weblogs.sqlteam.com/mladenp |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-11-01 : 11:30:39
|
quote: Originally posted by spirit1 well that depends on which time you want to have.SQL server's time or web servers time. this can be a difference if they're in differnet timezones.Go with the flow & have fun! Else fight the flow blog thingie: http://weblogs.sqlteam.com/mladenp
Oh yeah. Forgot that i am not in a timezone-challenged area. KH |
|
|
SherryT
Starting Member
6 Posts |
Posted - 2006-11-01 : 11:31:27
|
This is the error I am gettingRun-time error ‘3709’:The connection cannot be used to perform this operation. It is either closed or invalid in this context. |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2006-11-01 : 11:41:46
|
you're not setting the connection to your command so there is no connection to run this query against.Go with the flow & have fun! Else fight the flow blog thingie: http://weblogs.sqlteam.com/mladenp |
|
|
SherryT
Starting Member
6 Posts |
Posted - 2006-11-01 : 11:43:49
|
Can you please show that in code? Thanks |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
|
SherryT
Starting Member
6 Posts |
Posted - 2006-11-01 : 12:25:39
|
Thanks. I'll work on it. |
|
|
SherryT
Starting Member
6 Posts |
Posted - 2006-11-01 : 13:19:56
|
I got it. I forgot to add cmd.ActiveConnection = TconnThank you spirit1. |
|
|
|