session counter

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2007
Posts: 276
Reputation: rapture has a spectacular aura about rapture has a spectacular aura about 
Solved Threads: 37
rapture rapture is offline Offline
Posting Whiz in Training

session counter

 
0
  #1
Oct 18th, 2009
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

  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.
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC