Can' update access mdb with asp.net VB Microsoft.Jet.OLEDB.4.0

J

jason

Perhaps this is the wrong group - but having no luck. My source is
below . I am able to add and delete with similar code. I get no errors
messages. Displays look good. thank you for any help or information.


<code>

Public Sub UserGrid_Update (Source As Object, E As
DataGridCommandEventArgs)
Dim objConn as new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=db.mdb")

Dim cmd As OleDbCommand = new OleDbCommand ("UPDATE tbl SET
responsible=@responsible,status=@status,waitingon=@waitingon,comments=@comments
WHERE chain=@chain", objConn)


Dim schain As String = e.Item.Cells(2).Text
Dim sresponsible As String = CType(e.Item.Cells(3).Controls (0),
TextBox).Text
Dim sstatus As String = CType(e.Item.Cells(4).Controls (0),
TextBox).Text
Dim swaitingon As String = CType(e.Item.Cells(5).Controls (0),
TextBox).Text
Dim scomments As String = CType(e.Item.Cells(6).Controls (0),
TextBox).Text


response.write(schain+"-"+sresponsible+"-"+sstatus+"-"+swaitingon+"-"+scomments)

cmd.Parameters.Add(new OleDbParameter("@chain", schain))
cmd.Parameters.Add(new OleDbParameter("@responsible",
sresponsible))
cmd.Parameters.Add(new OleDbParameter("@status", sstatus))
cmd.Parameters.Add(new OleDbParameter("@waitingon", swaitingon))

cmd.Parameters.Add(new OleDbParameter("@comments", scomments))

Try

objConn.Open()
cmd.ExecuteNonQuery()
objConn.Close

Catch ex As Exception
response.write(ex.Message & ex.stacktrace)
End Try


</end code>
 
G

Guest

Hi Jason,

Have you checked the update statement to make sure that schain is being
populated correctly? If it is run that statement from inside Access and see
if it works. If it is not getting populated with the correct information
then the UPDATE Command will not find a row to update. Resulting in no error
but also no row updated. If this is not it please reply to this post with
details so the group may help you more.

Good Luck.
 
J

jason

yes, all the s values display as expected.

I don't know the access 2000 rdbms, where can I execute an update
statement?
 
J

jason

I can make the update work with fixed values. all the s variables are
getting set, only the @chain gets set however, all others @varialbes
either revert back or are never passed to the update. any idea?
 
G

Guest

Hi Jason,

Sorry for the late reply. You can run update statements within Access by
going to the query designer creating a new query and then pulling down the
box in the upper left hand corner to the SQL icon. If you can't find it look
up "View or modify the SQL statement behind an existing query" in the Access
help.

Can you post the code so I can give it a look? I took the code that you
have in your first post and ran it in a sample program and it ran fine.
This leads me to believe that the problem lies in the section of code that
populates the values of the query. Have you tried to create a sample program
to see if you can emulate the behavior? If you have can you post this code?
Please reply to this post so the group may help you better.

I look forward to your reply.
----------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top