Trying to update exiting code for specific date

  • Thread starter Thread starter lmnorms1
  • Start date Start date
L

lmnorms1

Hello,
I am trying to update an access database record date field that matches
a specific date. The code is not working. Anyone have any advice?

Here is the code:
Dim gConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Customer development\VBNET\CSFV\CSFV.mdb;"
Dim Conn As New OleDbConnection(gConnString) 'Actual
Connection to database.
Conn.Open()

Dim SqlStatement As String = "UPDATE LetterData " & _
"Set DateSenttoPrint = #" & shtDt & "# " & _
"WHERE ID = '" & RecordID & "' " & _
";"

Dim Command As New OleDbCommand(SqlStatement, Conn)
Command.ExecuteNonQuery()

Command.ExecuteNonQuery is were the code crashes.

Any advice would be apprieciated.
(e-mail address removed)
 
Thank you, I will look at the information. I forgot to mention (hope
this doesn't change the answer but) the database and record current has
a reader attached to it before the update. So, The reader is done to
find the record then I want to update it, how is the question?

Thanks for any information.
 
I didn't see anything on that website about updating a record. Do you
have another resource to view?
 
Hello,
I hit upon a website that says Reader is only for reading data. Is that
true? Should I use an adapter for doing updating?
 
The simplest way as you do it, is as you trying to do therefore try that at
least first: be aware that in this way you are not checking if somebody else
has done a concurrent update.

Cor
 
ISSUE is resolved. Thank you all that helped.

Loaded array with unigue ID as the reader was going line by line. Then
when done with reader before exiting the module called another function
to step thru the array to update the table with date sent to print.

Works like a charm.
 
Back
Top