Connecting Tech Pros Worldwide Help | Site Map

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

jason@cyberpine.com
Guest
 
Posts: n/a
#1: Nov 13 '05
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.

billmiami2@netscape.net
Guest
 
Posts: n/a
#2: Nov 13 '05

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


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.

jason@cyberpine.com
Guest
 
Posts: n/a
#3: Nov 13 '05

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



billmiami2@netscape.net wrote:[color=blue]
> Are you sure that this code is actually running? Is this procedure[/color]
set[color=blue]
> 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.[/color]


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

jason@cyberpine.com
Guest
 
Posts: n/a
#4: Nov 13 '05

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


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?

billmiami2@netscape.net
Guest
 
Posts: n/a
#5: Nov 13 '05

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


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

jason@cyberpine.com wrote:[color=blue]
> 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?[/color]

Closed Thread


Similar Microsoft Access / VBA bytes