Updating Access 2000 Records in .NET

  • Thread starter Thread starter Nathan
  • Start date Start date
N

Nathan

Hi, I need some help. I have a on button click event that goes through a
survey and reads the items they choose and then updates the current record.
The problem I'm having is that nothing actually is written back to the
database even though it runs the command. An append query works just fine.
any help would be appreciated.

<script runat="server">

Sub button_click(s as object, e as eventargs)
dim conUpdate as OleDBConnection
dim cmdUpdate as OleDBCommand

Dim strInput as String = Session( "UniqueID" )
Dim strSQL as String

conUpdate = New OleDbConnection ( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
SOURCE=d:\amcat\data\3001 eMortgage Survey.mdb" )
strSQL = "Update Campaign Set q1=@q1, q2=@q2, q3=@q3, q4=@q4, q5=@q5,
q6=@q6, q7=@q7, q8=@q8, q9=@q9, q10a=@q10, q10b=@q10b Where
uniquekey=@uniquekey"
cmdUpdate = New OleDBCommand( strSQL, conUpdate)
cmdUpdate.Parameters.Add( "@uniquekey", strInput )
'cmdUpdate.Parameters.Add( "@q1", aq1.Selectedvalue )
'cmdUpdate.Parameters.Add( "@q2", aq2.Selectedvalue )
cmdUpdate.Parameters.Add( "@q3", aq3.Selectedvalue )
cmdUpdate.Parameters.Add( "@q4", atxtq4.Text )
cmdUpdate.Parameters.Add( "@q5", aq5.Selectedvalue )
cmdUpdate.Parameters.Add( "@q6", aq6.Selectedvalue )
cmdUpdate.Parameters.Add( "@q7", aq7.Selectedvalue )
cmdUpdate.Parameters.Add( "@q8", aq8.Selectedvalue )
cmdUpdate.Parameters.Add( "@q9", aq9.Selectedvalue )
cmdUpdate.Parameters.Add( "@q10", aq10.Selectedvalue )
cmdUpdate.Parameters.Add( "@q10b", aq10b.Text )
lblAlert.Text = strSQL
conUpdate.Open()
cmdUpdate.ExecuteNonQuery()
conUpdate.Close()

End Select
End Sub

thanks
Nathan
 
The order you add your parameters has to match the order they appear in your
query and uniquekey is out of sequence. I think that's the source of your
problem.

HTH,

Bill
 
Back
Top