MsAccess INSERT INTO problem, please help me out

Results 1 to 4 of 4

Thread: MsAccess INSERT INTO problem, please help me out

  1. #1
    Lodewijk Guest

    Default MsAccess INSERT INTO problem, please help me out

    I have to insert some data in my ORDERS table from my Books.mdb database.<BR>I tested my sql command in MsAccess and it works:<BR><BR>I use the following subroutine to send update, delete or insert commands to my database (actions that do not return a recordset):<BR>Sub SQLExecute(sql)<BR> Dim strProvider<BR> Dim con<BR> strProvider = "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:Mijn documentenBooks.mdb;"<BR> Set con = Server.CreateObject("ADODB.Connection")<BR> con.Open strProvider<BR> con.Execute sql &#039####<BR> con.Close<BR> Set con = nothing<BR> Set strProvider = nothing<BR>End Sub<BR><BR>Then I use that in my code as (userid and itemid are defined):<BR> strQuery = "INSERT INTO ORDERS (USERID, ITEMID, QNT) VALUES (" & userid &" ," & itemid & " , 1);"<BR> SQLMakeRS rst, strQuery<BR>The driver errors an &#039 80040e10&#039 error and tells me on the #### line that there are not enough parameters, expect number of parameters is 1.<BR><BR>I am really stuck (I tried to put my userid in quotes..my userid looks like 14799161524-LLLYKPF8 that is a combination of time and a random string, but that doesn&#039t matter)...<BR>Maybe the reason can be that I don&#039t specify all my fields in the ORDER table. I have put some defaults setings for the rest. <BR>Perhaps the ODBC driver doesn&#039t accept not specified fields, and Access does...<BR>I am lost..please help me<BR>

  2. #2
    Jeremy S. Guest

    Default RE: MsAccess INSERT INTO problem, please help me out

    Sounds like a bad SQL statement.<BR><BR>Why don&#039t you throw in a Response.Write(sql) so that you can see what the Execute method is trying to run.<BR><BR>If you could provide value of the sql line (not the expression that builds it) it would help in trouble-shooting.

  3. #3
    Jeremy S. Guest

    Default RE: MsAccess INSERT INTO problem, please help me out

    If userid is a character data type, you will need to supply quotes around it.<BR><BR>Try something like this (assuming userid and itemid are not numbers)...<BR><BR>strQuery = "INSERT INTO ORDERS (USERID, ITEMID, QNT) VALUES (&#039" & userid &"&#039 ,&#039" & itemid & "&#039 , 1);"<BR><BR>Notice the single quotes. Give this a try.<BR><BR>Good Luck.<BR><BR>-- Jeremy S.

  4. #4
    Lodewijk Guest

    Default RE: MsAccess INSERT INTO problem, please help me out

    Thanks Jeremy for picking up my problem,<BR><BR>the wierd thing is the problem solved itself (with the quotes I allready tryed before..no result) after I restarted my computer..X-files stuff.<BR><BR>No it works smooth and cool,<BR>thanks anyway!<BR>Drop me a line if you have a problem.<BR>=)<BR>Lokey


Posting Permissions

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