i'm using ms access but no problem will try it though.
thanks all
a l i
----- Original Message -----
From: "Mark E" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 22, 2004 11:15 PM
Subject: Re: [ASP] import a csv file into ms access using asp.
> Hi,
>
> Below is some code that I use to open a csv file, parse out the values I
need and send them to a function that inserts them into a SQL database.
>
> I removed some things in an attempt to keep it short and simple, like
error checking, the actual insert code, etc.
>
> Mark
>
> <%
>
>
'***************************************************************************
***********************'
> '** This page is used to load records from an Excel spreadsheet into the
SQL database. **'
>
'***************************************************************************
***********************'
>
> Const ForReading = 1
> Const strConnectionString = "Driver={SQL
Server};Server=TestServer;Database=DBName;User
Id=Your_ID;Password=Your_Password;"
>
> Dim myFile, objTextFile, strText
> Dim objFSO, strPath
> Dim strErrorLogString, strFailedCount, strFileNameToOpen
> Dim myOutputFile
>
> 'Global vars for holding new item values.
> Dim strValue1, strValue2
>
> 'Reset our variables.
> strValue1 = ("")
> strValue2 = ("")
>
> 'Create our FSO.
> set objFSO = Server.CreateObject("scripting.FileSystemObject")
>
> 'Set our source file name to open.
> strFileNameToOpen = ("\PaymentList.csv")
>
> 'Set our path & file name.
> strPath = server.MapPath("PaymentList") & strFileNameToOpen
>
> 'Check to make sure the file exists before we process.
> if objFSO.FileExists(strPath) then
>
> 'Get the file that we will be reading.
> set myFile = objFSO.GetFile (strPath)
>
> 'Open the text file.
> set objTextFile = myFile.OpenAsTextStream(ForReading, -2)
>
> 'Loop thru the text file and get all the text, assign to variable.
> Do While not objTextFile.AtEndOfStream
>
> 'Grab each line in the file, store in variable.
> strText = objTextFile.ReadLine
>
> 'Evalute the line to see if data exists.
> if len(trim(strText)) > 0 then
> 'The line is not blank, process.
>
> 'Get the line into an array.
> strMyArray = split(strString, ",")
>
> 'Get our values from the array.
> strValue1 = (strMyArray(0))
> strValue2 = (strMyArray(1))
>
> 'Now pass the values to a function that inserts the record.
> InsertNewPaymentRecord(strValue1, strValue2)
>
> end if
> Loop
>
> 'Close & destroy the file.
> objTextFile.close
> set objTextFile = nothing
>
> end if
>
> %>
>
> aliadon <[EMAIL PROTECTED]> wrote:
> hi all,
>
> would like to seek a solution on how to import a csv file to a database
using asp.
>
> rgds
> a l i
>
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
>
> ---------------------------------------------------------------------
> Home : http://groups.yahoo.com/group/active-server-pages
> ---------------------------------------------------------------------
> Post : [EMAIL PROTECTED]
> Subscribe : [EMAIL PROTECTED]
> Unsubscribe: [EMAIL PROTECTED]
> ---------------------------------------------------------------------
>
>
> Yahoo! Groups SponsorADVERTISEMENT
>
>
> ---------------------------------
> Yahoo! Groups Links
>
> To visit your group on the web, go to:
> http://groups.yahoo.com/group/active-server-pages/
>
> To unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
>
> ---------------------------------------------------------------------
> Home : http://groups.yahoo.com/group/active-server-pages
> ---------------------------------------------------------------------
> Post : [EMAIL PROTECTED]
> Subscribe : [EMAIL PROTECTED]
> Unsubscribe: [EMAIL PROTECTED]
> ---------------------------------------------------------------------
> Yahoo! Groups Links
>
>
>
>
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/17folB/TM
--------------------------------------------------------------------~->
---------------------------------------------------------------------
Home : http://groups.yahoo.com/group/active-server-pages
---------------------------------------------------------------------
Post : [EMAIL PROTECTED]
Subscribe : [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
---------------------------------------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/active-server-pages/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/