Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 16th, 2004, 05:55 PM
Registered User
 
Join Date: Sep 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default [ODBC Excel Driver]Syntax eror in update

Hi!
I have to do an ASP script that updates some columns in four MS Excel files, based on the SQL Server data. For 2 days I have an error :

Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Excel Driver] Syntax error in UPDATE statement.

This is the code I use for the update statement:

while not objRS.EOF


obj1RS.Source = "Select CECAND_PACODE, CURR_BUNDLEID, CURR_BUNDLEDDEALER, CECAND_LAST_AUTH FROM CE_CANDEALER where CECAND_PACODE ='" & objRS.Fields.Item(1).Value & "'"
obj1RS.Open

if objRS.Fields(1).Value=obj1RS.Fields(0).Value then
objRS.Fields(1).Value=obj1RS.Fields(0).Value

if obj1RS.Fields(1).Value= "3" then
objRS.Fields(3).Value="S"

else
objRS.Fields(3).Value=obj1RS.Fields(1).Value
end if
response.Write("aici1")
if obj1RS.Fields(2).Value="1" then
objRS.Fields(5).Value="xx"
elseif obj1RS.Fields(2).Value="0" then
objRS.Fields(5).Value="ww"
else
objRS.Fields(5).Value="ss"
end if

'if obj1RS.Fields(3)<>"" then
'objRS.Fields(4)="y"
'else
'objRS.Fields(4).Value=obj1RS.Fields(3).Value
'end if


end if


objRS.Update
objRS.MoveNext
obj1RS.Close
wend

In my opinion everything should be ok, but obviously is not.

I changed the permissions for IUSR_x(full control) and I did many other things that I found on google.
If there is anybody who had the same problem and knows an answeer, please email me:(
Thanks


 
Old September 17th, 2004, 12:17 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Are you updating an excel sheet with this code ?

If yes, the excel tables (equivalent to worksheets) start with $ symbol. $Sheet1 etc. If we omit that, it will give a similar error.

The other reason may be that one of the fields of excel sheet has a keyword as the header (field name). Password, name, date etc. are keywords.

Please post the portion of the code which sets the recordset objRS. And also the data types of fields. This will help us give you more idea.
 
Old September 17th, 2004, 03:14 AM
Registered User
 
Join Date: Sep 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi again!
This is the code for recordset objRS:
 Set objConn = Server.CreateObject("ADODB.Connection")
 objConn.Open "Ram2"
 Set objRS = Server.CreateObject("ADODB.Recordset")
 objRS.ActiveConnection = objConn
Everything is fine here, the select statement from Excel and SQL works and in Excel I don't have keyword names:(
Yesterday I tried the following version for the update, but also didn't work:
While Not objRS.EOF
         Response.Write("<TR>")
        'Response.Write " Select CECAND_PACODE, CURR_BUNDLEID, CURR_BUNDLEDDEALER, CECAND_LAST_AUTH FROM CE_CANDEALER where CECAND_PACODE =" & objRS.Fields.Item(1).Value
             Set obj1RS = Server.CreateObject("ADODB.Recordset")
             obj1RS.ActiveConnection=obj1
            'obj1RS.Source = "Select CURR_BUNDLEID, CURR_BUNDLEDDEALER, CECAND_LAST_AUTH FROM CE_CANDEALER where CECAND_PACODE ='" & objRS.Fields.Item(1).Value & "'"
            obj1RS.Open
       'this works

                Response.write(" - 1) " & obj1RS.Fields.Item(0).Value)
                'Response.write(" - 2) " & obj1RS.Fields.Item(1).Value)
                'Response.write(" - 3) " & obj1RS.Fields.Item(2).Value)

        'update
        dim d

        if(obj1RS.Fields(0).Value = "3") then
            d="S"
        else
            d = obj1RS.Fields(0).Value

        end if
       ' if(obj1RS.Fields(1).Value="1") then
            objRS.Fields(6).Value="Y"
                    '
        elseif(obj1RS.Fields(1).Value="0") then
            objRS.Fields(6).Value="N"

        else
            objRS.Fields(6).Value=" "
        end if
          'this doesn't work
             excelString="Update Ram2 Set [$YES/NO]='" & d & "' "

             objConn.Execute(excelString)
             objrs.Update
             obj1RS.Close
         set obj1RS= nothing
          Response.write("<br /></TD>")

         objRS.MoveNext
         Response.Write("</TR>")
         Wend
As you can see I put $ sign.
Do you have any ideea what is happening?

 
Old September 17th, 2004, 04:00 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

The query which sets objRS is not there. May be you have some security problems in posting it ?

Please use $ only for tablename (worksheet name) of excel.

i.e. excelString=="Update $Ram2 Set [YES/NO]='" & d & "' ". This also will not work as [YES/NO] is not a valid field.

Here is the correct connection string to an excel file.

"Data Source=<absolute path to excel file>\sample.xls" & ";" & _
                "Extended Properties=""Excel 8.0;"""

And I found that you are not checking obj1RS has got any rows. Please check that also.

It is always better to do updation through direct SQL statement rather than using .update method of ADO object. Then you can print the query and check whether there is anything wrong there.





Similar Threads
Thread Thread Starter Forum Replies Last Post
SQLException in using odbc excel driver lironnezers Java Databases 2 December 20th, 2010 08:02 AM
Rdb ODBC Driver Eron Oracle 0 March 9th, 2005 04:32 AM
[Microsoft][ODBC Microsoft Access Driver] Syntax e chinedu Classic ASP Databases 3 November 18th, 2004 03:48 PM
ODBC driver for Teradata clueless_may Access VBA 0 November 1st, 2004 11:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.