Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms 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 December 9th, 2004, 04:59 AM
Authorized User
 
Join Date: Oct 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to kiwibey
Default Copy Excel file to database

hi everybody,
below is my source code...
why i got this funny error 1 ?

<%
    branchexcelpath = request.form("branchexcelpath")
    Dim Conn, RS
    Set Conn = CreateObject("ADODB.Connection")
    Set RS = CreateObject("ADODB.Recordset")

    Dim Conn_str, rs1, SQL1
    Set Conn_Str = Server.CreateObject("ADODB.Connection")
    Conn_str.Open "Provider=SQLOLEDB;Data Source=stardocs-1foniw;UID=sa;PWD=sa;DATABASE=checklistsystem"
    session("a")=b
    conn_Str.Execute "delete from BranchList where REcid <> '"&session("a")&"'"


    XLFile = branchexcelpath

    szSQL = "select * from Events"

    '## Create and open the connection
    Conn.ConnectionString = "DBQ=" & XLFile & ";DRIVER=Microsoft Excel Driver (*.xls);"
    Conn.Open

    '## set the cursor to be static.
    rs.cursortype = 3 ' adStatic.

    '## open the recordset
    rs.open szSQL, conn

    x=0

    '## iterate through the recordset.
    while not rs.eof
    x=x+1

  session("AuthorisedDate") = RS("Authorised Date")
  session("RECID") = RS("REC ID")
  session("Branch") = RS("Branch")
  session("Subsource") = RS("Subsource/unit")
  session("PolicyNo") = RS("Policy No")
  session("AgentCode") = RS("Agent Code")
  session("SubmissionDate") = RS("Submission Date")
  session("InsuredName") = RS("Insured Name")
  session("Class") = RS("Class")



      Set rs1 = Server.CreateObject("ADODB.Recordset")
      SQL1 = "insert into BranchList(AuthorisedDate,RECID,Branch,SubSource,P olicyNo,AgentCode,SubmissionDate,InsuredName,Class ) values('"&session("AuthorisedDate")&"','"&session( "RECID")&"','"&session("Branch")&"','"&session("Su bsource")&"','"&session("PolicyNo")&"','"&session( "AgentCode")&"','"&session("SubmissionDate")&"','" &session("InsuredName")&"','"&session("class")&"') "
      Set rs1 = conn_str.execute(SQL1)

      rs.movenext
      wend

    'response.write x
    RS.close
    Set RS=nothing

    response.redirect "copycomplete2.asp"
%>

the error is as below....


Error Type:
Microsoft OLE DB Provider for SQL Server (0x80040E14)
Line 1: Incorrect syntax near 'NG'.
/DataCheckList/DataCheckList/compare/branchexcel.asp, line 48


please help me....
i become mad yet...
thanks...

bey

 
Old December 13th, 2004, 02:49 AM
Registered User
 
Join Date: Dec 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi kiwibey

i think the error may be in the SQl string that u are trying to execute with the statement "Set rs1 = conn_str.execute(SQL1)"
there may be a single quote "'" in one of the parameters being passed in the insert statement.
to check it try printing the sql statement by

response.write SQL1
response.end

before the line "Set rs1 = conn_str.execute(SQL1)"

 
Old December 13th, 2004, 02:54 AM
Registered User
 
Join Date: Dec 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi kiwibey,

the error is coming while executing the insert command, please check the insert command by printing it using response.write, this error will come if some of your values are having single quote or double quote,

I hope this will helps u,



Satish Kumar J
 
Old December 14th, 2004, 05:30 AM
Authorized User
 
Join Date: Oct 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to kiwibey
Default

hi mbhatnagar and satishkumarj :
thank you so much for your advice...
i had find the error because of single quote..
so after i remover all the single quote.
then everything was run normally....

bey






Similar Threads
Thread Thread Starter Forum Replies Last Post
Read excel file into database wk ASP.NET 2.0 Basics 7 June 12th, 2007 06:53 AM
Import Excel File to access database Komila ASP.NET 1.0 and 1.1 Professional 7 October 7th, 2006 12:45 AM
How to Covert Excel to Text file as Database narendra_patil ASP.NET 1.x and 2.0 Application Design 1 July 20th, 2005 03:01 PM
Copy cells from an excel file opened in a browser escorido Excel VBA 0 July 6th, 2004 01:44 AM





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