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
|