Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2006
    Posts
    80
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Javascript and Client Side ADO with Access Database

    Ok, I'm about to tear my hair out. I'm trying to add a record to an Access database using the following code:

    Code:
     
     var uAns = document.getElementById("uChoices");
     //..........connection string............//
     
     yrAnswer-=0
     yScore-=0
     var iStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\userRecs.mdb";
     var adOpenKeyset = 1;
     var adLockOptimistic = 3;
     var adCmdText = 1;
     var adUseClient = 3;
     //..........................................//
     //.............ActiveX Setup............//
     var cObj = new ActiveXObject("ADODB.Connection");
     var recSet = new ActiveXObject("ADODB.Recordset");
     
     recSet.CursorLocation = adUseClient;
     cObj.CursorLocation = adUseClient;
     
     cObj.Open(iStr)
     var grStr = "SELECT * FROM " + uId
     
     
     recSet.Open(grStr,cObj,adOpenKeyset,adLockOptimistic,adCmdText)
     recSet.AddNew;
     recSet.Fields("Question_Number").value = 0
     recSet.Fields("Your_Answer").value = yrAnswer
     recSet.Fields("Score_for_This_Question").value = yScore
     recSet.Fields("Possible_Score_For_This_Question").value = availScore.value
     
     recSet.Update;
     recSet.close

    Now this code appears to work fine until it gets to this line:
    Code:
     
    recSet.Fields("Your_Answer").value = yrAnswer
    At this point I get this error: "Multiple Step operation generated errors. Check all values". After lots of Googling I found out that it usually means you're trying to add a value with an invalid data type into the field. So at this point I googled again and found something on DevNet which says you can use rs.DefinedSize to set the size of the field. But not until the value of the field has been set and not until after the rs.Update method has been used to update the database. So I tried this. I then got an error saying that I couldn't use DefinedSize method while the connection was open. So I closed it. It still didn't work because I'm trying to add a value that is too large to a field in the table (the yrAnswer variable). So this is the problem:

    1. I can't add the value to the field first because the value is too large
    2. I can't change the DefinedSize property of the field until AFTER the value attribute of the Field object has been set and the Update method called.

    How do I get the value in, or set the field size, and in which order? Google has been semi helpful, but I can't find much on Javascript and ADO.

    All help appreciated.

    Joe
    http://www.Kanotix.com --My OS of choice, the best hardware detection on the planet!-
    http://distrowatch.com -Linux is the future-
    http://www.packetstormsecurity.org -Security Gurus-

  • #2
    New Coder
    Join Date
    Dec 2006
    Posts
    80
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Never mind, I sorted it out. It wasn't that I needed to alter the size, it was that I needed to define the field type with the correct constant while creating the table using ADOX.

    Cheers anyhow
    Joe
    http://www.Kanotix.com --My OS of choice, the best hardware detection on the planet!-
    http://distrowatch.com -Linux is the future-
    http://www.packetstormsecurity.org -Security Gurus-


  •  

    Posting Permissions

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