Results 1 to 9 of 9

Thread: Can't Update Database (Resovled)

  1. #1

    Thread Starter
    Addicted Member señorbadger's Avatar
    Join Date
    Oct 2003
    Location
    Mud pools of wellingborough
    Posts
    193

    Angry Can't Update Database (Resovled)

    Hi when i try to update my db i get this error



    this is the code that it has a problem with

    VB Code:
    1. Set myrs = New ADODB.Recordset
    2.         'set the varible to get ready
    3. Set MyConn = New ADODB.Connection
    4.         'set the varible to get ready
    5.     connstr = "Provider=MS Remote;" & _
    6.            "Remote Server=http://192.168.0.2;" & _
    7.            "Remote Provider=Microsoft.Jet.OLEDB.4.0;" & _
    8.            "Data Source=C:\Inetpub\wwwroot\BCIMusrs.mdb"
    9.            MyConn.ConnectionString = connstr
    10.     MyConn.Open
    11.  
    12. 'the line below is the problem the stuff above might help i think
    13.  
    14. Set myrs = MyConn.Execute("UPDATE users SET ScreenName = '"
    15. & userscrname & "' WHERE Username ='" & employeeperson & "'")

    Please Help

    Sam Lad
    Last edited by señorbadger; Dec 14th, 2003 at 11:44 PM.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Since there is no recordset being returned.... you don't need the set.... just this:
    VB Code:
    1. MyConn.Execute("UPDATE users SET ScreenName = '"
    2. & userscrname & "' WHERE Username ='" & employeeperson & "'")

    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Addicted Member señorbadger's Avatar
    Join Date
    Oct 2003
    Location
    Mud pools of wellingborough
    Posts
    193
    thanks but still same error
    this is the code now

    VB Code:
    1. Set MyConn = New ADODB.Connection
    2.         'set the varible to get ready
    3.     connstr = "Provider=MS Remote;" & _
    4.            "Remote Server=http://192.168.0.2;" & _
    5.            "Remote Provider=Microsoft.Jet.OLEDB.4.0;" & _
    6.            "Data Source=C:\Inetpub\wwwroot\BCIMusrs.mdb"
    7.            MyConn.ConnectionString = connstr
    8.     MyConn.Open
    9. MyConn.Execute ("UPDATE users SET ScreenName = '" &
    10. userscrname & "' WHERE Username ='" & employeeperson & "'")
    Last edited by señorbadger; Dec 10th, 2003 at 04:26 PM.

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Hmm... remote accessing an MDB? You will have problems...

    Remove the parentheses:

    VB Code:
    1. Set MyConn = New ADODB.Connection
    2.         'set the varible to get ready
    3.     connstr = "Provider=MS Remote;" & _
    4.            "Remote Server=http://192.168.0.2;" & _
    5.            "Remote Provider=Microsoft.Jet.OLEDB.4.0;" & _
    6.            "Data Source=C:\Inetpub\wwwroot\BCIMusrs.mdb"
    7.  
    8.  
    9.     MyConn.Open connstr
    10.  
    11. MyConn.Execute "UPDATE users SET ScreenName = '" &
    12. userscrname & "' WHERE Username ='" & employeeperson & "'"

  5. #5
    Fanatic Member
    Join Date
    Sep 2000
    Posts
    770
    If the .mdb file is opened (meaning you have it openend in MS Access) or if you are hosting this from a server and the IUSR account has no read permissions on the folder/file you are writting to then, in both cases, you will get that error.

  6. #6
    Junior Member
    Join Date
    Jul 2003
    Posts
    25
    You'll get this error if the table does not have a primary key established. Check to see if you do. If you don't, put one on it, even if you just add an identity field and make it the primary key.

  7. #7

    Thread Starter
    Addicted Member señorbadger's Avatar
    Join Date
    Oct 2003
    Location
    Mud pools of wellingborough
    Posts
    193
    done both of those IUSR has write permissions still same problem

    help please !

  8. #8

  9. #9

    Thread Starter
    Addicted Member señorbadger's Avatar
    Join Date
    Oct 2003
    Location
    Mud pools of wellingborough
    Posts
    193
    Ado is in type read only so now i ammended that, also field names were reserved words for connection (how foolish of me)


    thanks all

    this is the code to solve the issue
    VB Code:
    1. Dim MyConn As ADODB.Connection
    2.      Set MyConn = New ADODB.Connection
    3.  
    4.          MyConn.ConnectionString = "Provider=MS Remote;" & _
    5.                 "Remote Server=http://127.0.0.1;" & _
    6.                 "Remote Provider=Microsoft.Jet.OLEDB.4.0;" & _
    7.                 "Data Source=C:\Inetpub\wwwroot\db.mdb"
    8.   MyConn.CursorLocation = adUseClient 'open the database in r/w mode
    9.   MyConn.Open
    10.  
    11. MyConn.Execute ("UPDATE users SET UserPWD = '" _
    12. & TxtnewPWD.Text & "' WHERE UserID ='" & username & "'")

    so to write back pick sensible field names and before you open
    (like the line before type)

    VB Code:
    1. MyConn.CursorLocation = adUseClient

    thanks again all !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width