944,014 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 307
  • ASP.NET RSS
Oct 18th, 2009
0

session counter

Expand Post »
Another problem in my program is that I can't get my access database to update. It works on the other fields here is the code

ASP.NET Syntax (Toggle Plain Text)
  1. Public Sub Lockuser(ByVal path As String, ByVal userId As String, ByVal access As Boolean)
  2.  
  3.  
  4. Dim sqlConn As OleDbConnection
  5.  
  6. Dim oCommand As OleDbCommand
  7.  
  8. Dim stmt As String
  9.  
  10. Dim param As OleDbParameter
  11.  
  12. ' This sets up the connection to the database including the path passed in
  13.  
  14. sqlConn = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & path & "")
  15.  
  16. sqlConn.Open()
  17.  
  18. oCommand = New OleDbCommand()
  19.  
  20. oCommand.Connection = sqlConn
  21.  
  22.  
  23. stmt = "UPDATE tblUsers SET Access = @access" & " WHERE(tblUsers.UserID = @userId)"
  24.  
  25. 'declare parameter objects for the command object
  26.  
  27. param = New OleDbParameter()
  28.  
  29. param.ParameterName = "@userId"
  30.  
  31. param.Value = userId
  32.  
  33. oCommand.Parameters.Add(param)
  34.  
  35. param = New OleDbParameter()
  36.  
  37. param.ParameterName = "@access"
  38.  
  39. param.Value = False
  40.  
  41. oCommand.Parameters.Add(param)
  42.  
  43. oCommand.CommandText = stmt
  44.  
  45. oCommand.CommandType = CommandType.Text
  46.  
  47. oCommand.ExecuteNonQuery()
  48.  
  49. sqlConn.Close()
  50.  
  51. End Sub

I've tried a yes/no and text field but it won't update in access. Am I missing a step?
Last edited by rapture; Oct 18th, 2009 at 3:07 pm.
Similar Threads
Reputation Points: 155
Solved Threads: 41
Posting Whiz in Training
rapture is offline Offline
294 posts
since Jul 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: how can I invoke browser's network authentication dialogue box in asp.net
Next Thread in ASP.NET Forum Timeline: session counter





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC