Cant write to database!!

Results 1 to 4 of 4

Thread: Cant write to database!!

  1. #1
    Join Date
    Dec 1969

    Default Cant write to database!!

    Im having a problem writing to this table. I can read from it no problem, but when i try and update the table with new info, it keeps giving me grief. I have used this exact same db connection for many other tables with no problems. It keeps giving me a error message like this: <BR>Microsoft OLE DB Provider for ODBC Drivers error &#039 80040e21&#039 <BR><BR>[Microsoft][ODBC Microsoft Access 97 Driver] Syntax error in INSERT INTO statement. <BR><BR>/bidlists/submit_bid_mail.asp, line 40 <BR><BR>my code is listed below:<BR><BR>id=session("login")<BR> rm("co")<BR>bid=request.form("bid")<BR>stock=reque st.form("stock")<BR><BR>&#039 on error resume next<BR>query = "Select * from " & co & " where ("& co &".bidid)=" & id & ""<BR>(bidid is an actual fieldname, "id" and "co" are variables from previous page.) <BR>mydsn = "DSN=uinfo"<BR>Set Connect= Server.CreateObject("ADODB.Connection")<BR>Connect .Open mydsn<BR>Set cmddc= Server.CreateObject("ADODB.Command")<BR>cmddc.Acti veConnection=connect<BR>cmddc.CommandText=query<BR >Set addrecord = Server.CreateObject("ADODB.Recordset")<BR>addrecor d.Open cmddc,,0,2<BR>addrecord.AddNew<BR>addrecord("bidid ")= id<BR>addrecord("stockno")= stock <BR>addrecord("bid")= bid<BR>addrecord("count")= 1<BR>addrecord("date")= date<BR>addrecord.update (line 40) <BR>addrecord.close<BR>set addrecord=nothing<BR><BR>I&#039ve even tried the query just opening up all files like: <BR>query="Select * from " & co & ""<BR>"uinfo", the dsn, is pointed towards the access database named users in which the table "indaut" is a part of. &#039indaut&#039, is being passed by the request.form variable "co" from the previous page. <BR>

  2. #2
    Sathiya Guest

    Default RE: Cant write to database!!

    Change the column name DATE to someother varaibale because DATE is a Reserved word so it gives you this error.<BR><BR>

  3. #3
    b rian Guest

    Default RE: Cant write to database!!

    Thank you for your reply. You were exactly right, we figured it out right after lunch yesterday.

  4. #4
    Join Date
    Dec 1969

    Default RE: Cant write to database!!

    Just a guess, but try changing this line:<BR>addrecord.Open cmddc,,0,2<BR><BR>to this:<BR>addrecord.Open cmddc,Connect,2,2<BR><BR>This will explicilty set the "ActiveConnection" argument to the recordset open method to your connection and changing the 0 to a 2 will change the cursor type from adOpenForwardOnly to adOpenDynamic.<BR><BR>HTH -<BR>Joel

Posting Permissions

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