hi,
here is the error message :
<--cut-->
Microsoft OLE DB Provider for ODBC Drivers erreur '80004005'
[Microsoft][ODBC SQL Server Driver][SQL Server]There are more columns in the INSERT
statement than values specified in the VALUES
clause. The number of values in the VALUES clause must match the number of columns
specified in the INSERT statement.
/adpf_sql_w/publication/import.asp, ligne 86
<--cut-->
the reason i'm doing it in an asp page is because, i'm importing a .txt file to the
SQL server, and not just copying the tables. i
also have quite a lot of data transformation going on. but can this be done directly
from SQL?
i'm pretty shure the error is comming from the loop, but as i'm not creating the
INSERT statment on the fly (i'm letting asp handle
that, probably not a very wise idea) i don't know what field(s) is causing the error.
in case it's a stupid mistake in my asp code here it is
thanks
<--cut-->
' CONN & RS = the text file to import
' CONN2 & RS2 = the SQLServer to import to
DIM NumOfTablesToCopie
NumOfTablesToCopie = (3) - 1
DIM NameOfTableNum(3)
NameOfTableNum(0) = "adpfBiblio"
NameOfTableNum(1) = "auteurBiblio"
NameOfTableNum(2) = "noticeBiblio"
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.Recordset")
Set Conn2 = Server.CreateObject("ADODB.Connection")
Conn2.Open Application("adpf_ConnectionString")
Conn.Open "Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
"DBQ="& Server.MapPath(".") &"\uploadfiles\;" & _
"Extensions=asc,csv,tab,txt,mer"
for i=0 to 2
sql="delete from " & NameOfTableNum(i) & ";"
response.write SQL
Conn2.Execute(SQL)
next
for TableNum=0 to NumOfTablesToCopie
Set Rs2 = Server.CreateObject("ADODB.RecordSet")
SQLStr = "SELECT * FROM " & NameOfTableNum(TableNum) & ";"
response.write SQLStr
Rs.Open "SELECT * FROM " & NameOfTableNum(TableNum) & ".mer", Conn, 1, 3
Rs2.Open SQLStr, Conn2, 1, 3
while not rs.eof
rs2.addnew
for i=0 to rs.fields.count-1
rs2(i) = rs(i)
next
rs2.update
rs.movenext
wend
Rs.Close
Rs2.Close
next
Conn.Close
Conn2.Close
Set Conn = NOTHING
Set Rs = NOTHING
Set Conn2= NOTHING
Set Rs2 = NOTHING
<--cut-->
-----Message d'origine-----
De : Showbear [mailto:[EMAIL PROTECTED]]
Envoy� : mercredi 31 juillet 2002 14:20
� : ActiveServerPages
Objet : RE: error in SQL statment
Tim, what error are you getting? It's always a good idea to report
specifically what you're seeing.
Often, errors after initial success inside a loop are related to the
loop going too far for one of the objects being addressed. In your
example below, could i be going past the end of the rs2 recordset?
As an aside, it would probably be more efficient to do this kind of
copying inside the database by calling a stored procedure to do it
rather than iterating through the recordset one record at a time in ASP
code.
HTH
-----Original Message-----
From: Tim Fletcher [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 31, 2002 7:02 AM
To: ActiveServerPages
Subject: error in SQL statment
hi,
in a script, i'm populating a DB table using a
for i=1 to something
rs.addNew
rs(i)=rs2(i)
rs.upDate
next
but i get an error on the last update! can i somehow get the SQL query
the server is executing that is causing the error? using "on error", an
"rs" method or something similar?
TIA for your time
Tim
---
You are currently subscribed to activeserverpages as:
[EMAIL PROTECTED] To unsubscribe send a blank email to
%%email.unsub%%
---
You are currently subscribed to activeserverpages as: [EMAIL PROTECTED]
To unsubscribe send a blank email to %%email.unsub%%
---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]