'thisfile.txt is a text file, and I am using MySQL but not Access
'below is the code of what I am going to do with a text file. Please ignore
the typing errors when I make something changed from the original codes. If
the file is csv (thisfile.csv), it works fine.
sConnection="driver={MySQL ODBC 3.51
Driver};server=localhost;database=upload;uid=root; "
set conn=server.CreateObject("ADODB.Connection")
conn.open(sConnection)
constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & myPath &
"\;Extended Properties=""text;HDRNo;FMT=Delimited"""
set conn2=server.CreateObject("ADODB.Connection")
conn2.open(constr)
myPath="D:\uploadtemp\"
file_name = "thisfile.txt"
fileStr="select * from " & file_name
set dRs=conn2.execute(fileStr)
' insert the recordset into the database.
do until dRs.eof
insertStr="insert into file (filename "
for i = 1 to dRs.Fields.Count
insertStr=insertStr &", f" & i
next
insertStr = insertStr &") "
insertStr = insertStr & "values ('"&file_name&"'"
for k = 1 to dRs.Fields.Count
fieldata = dRs(k-1)
insertStr = insertStr &", '" & fieldata & "'"
next
insertStr = insertStr &") "
conn.Execute(insertStr)
dRs.MoveNext
loop
dRs.close : set dRs = nothing
conn.Close : set conn=nothing
conn2.Close : set conn2 = nothing
"Ray at <%=sLocation%>" <myfirstname at lane 34 . komm> wrote in message
news:ee**************@TK2MSFTNGP11.phx.gbl...
What is "thisfile.txt?" Is that the name of a table in an Access
database, or is that your filename? What is your code?
Ray at home
"atse" <du******@yahoo.com> wrote in message
news:q2********************@news01.bloor.is.net.ca ble.rogers.com...
When I try:
select * from thisfile.txt and then insert these records into a
designated table of the database.
the error message is:
Microsoft JET Database Engine error '80040e14'
Syntax error in FROM clause.
/insertfile.asp, line 46
' line 46 is
set rs = conn.execute("select * from thisfile.txt")