Waspman
Posts: 948
|
| Posted: 12/15/2006, 2:36 AM |
|
I got the working using;
---
dim objConn, strDBPath, SQL
set objConn= Server.CreateObject("ADODB.Connection")
strDBPath = Server.MapPath("../database/SMP.mdb")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & ";"
Dim csv_path
csv_path = Server.MapPath("./CSV") & "\"
SQL = "INSERT INTO Main_Stock SELECT * FROM ["&Request.QueryString("Filename")&"] IN """ & csv_path & """ ""TEXT;"""
objConn.Execute SQL
objConn.Close
Set objConn = Nothing
---
But, I have a part number field which is a text field in the database. Mostly the data in the CSV field numeric but occasionaly the number will have a letter in it. The data with the letter in it isn't being inserted.
Anybody any ideas why the format is being ignored?
Many thanks,
Tony
_________________
http://www.waspmedia.co.uk |
 |
 |
Waspman
Posts: 948
|
| Posted: 12/15/2006, 3:22 AM |
|
Sussed it, if any one has a similar problem...
This code works...
dim objconn, fso, act, csv_to_read
set objconn = Server.CreateObject("ADODB.Connection")
objconn.Provider="Microsoft.Jet.OLEDB.4.0"
objconn.Open Server.MapPath("../database/SMP.mdb")
csv_to_read= "./CSV/" & Request.QueryString("Filename")
set fso = createobject("scripting.filesystemobject")
set act = fso.opentextfile(server.mappath(csv_to_read),1,False)
dim sline
dim sSeg
Do Until act.AtEndOfStream
sline=act.readline
sSeg=split(sline,",")
dim strsql
strsql="INSERT INTO Main_Stock (Part, Description, Quantity, Location)"
strsql=strsql & "VALUES('"&sSeg(0)&"', '"&sSeg(1)&"', '"&sSeg(2)&"', '"&sSeg(3)&"')"
objconn.execute strsql
loop
act.close
set act=nothing
objconn.close
set objconn=nothing

_________________
http://www.waspmedia.co.uk |
 |
 |
|