By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,045 Members | 1,389 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,045 IT Pros & Developers. It's quick & easy.

updating access 2000 mdb from asp.net Microsoft.Jet.OLEDB.4.0 ???

P: n/a
I am able to add new records with insert and delete records just fine,
but when I go to update nothing happens. Below is the asp.net vc code
in question.

Public Sub UserGrid_Update (Source As Object, E As
DataGridCommandEventArgs)
Dim objConn as new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=c:\webroot\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

Thanks for any help or information.

Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Are you sure that this code is actually running? Is this procedure set
to handle the UpdateCommand in your page? Did you set the event
handler for the EditCommand (normally sets the EditItemIndex for the
datagrid)?

Bill E.

Nov 13 '05 #2

P: n/a

bi********@netscape.net wrote:
Are you sure that this code is actually running? Is this procedure set to handle the UpdateCommand in your page? Did you set the event
handler for the EditCommand (normally sets the EditItemIndex for the
datagrid)?

Bill E.

Yes, the response.write displays all the changed and expected values.

Nov 13 '05 #3

P: n/a
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?

Nov 13 '05 #4

P: n/a
Honestly, I've never used a SQL Syntax like that where I've combined
parameter names (not values) into a SQL String. I would recommend
creating a stored query for the update with a name (i.e.,
qryUpdateChain) and the parameters as you have them. Then run this as
a stored procedure by setting cmd.CommandType =
CommandType.StoredProcedure. This initialization of the command then
becomes

Dim cmd As OleDbCommand = new OleDbCommand ("qryUpdateChain", objConn)

cmd.CommandType = CommandType.StoredProcedure

See if your parameters are passed properly in this case.

Bill

ja***@cyberpine.com wrote:
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?


Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.