Google Answers Logo
View Question
 
Q: Upload Comma Deliminated File From IIS Directory and Append Results to Sql Table ( No Answer,   4 Comments )
Question  
Subject: Upload Comma Deliminated File From IIS Directory and Append Results to Sql Table
Category: Computers > Programming
Asked by: pmclinn-ga
List Price: $20.00
Posted: 13 Feb 2003 07:09 PST
Expires: 20 Feb 2003 13:31 PST
Question ID: 160882
I'm 3/4 of the way through a project and I'm stuck on the last part.
I have created a web page, that has a file import dialog box.  The
users click on an "upload" button and it asks them for the path to a
Comma Deliminated file [.rdl] after selecting the file,the path to the
file is saved in an object named UploadRequestForm("file") [Note: not
request.form("file")], and the users are directed to a new web page.

Now I have the new path of the file saved in the
UploadRequestForm("File") waiting to be pulled in and I want to upload
the contents of this file to a sql 2000 server.

Recap- my question is, I need Cut & Paste code that will allow me to
import-append this comma delimated file into SQL Server server table.

My Comma deliminated file looks like this:
1,Peter
2,Mike
3,Paul

My table looks like this:
IDKey - Primary Key, increments automatically
Record Number - First field in the comma delimated file (integer)
Name - 2nd field in the comma delaminated file.  (varchar 50)

Clarification of Question by pmclinn-ga on 13 Feb 2003 08:06 PST
Yes Asp.

Clarification of Question by pmclinn-ga on 19 Feb 2003 15:15 PST
Please release question if your not able to complete the answer.
Answer  
There is no answer at this time.

Comments  
Subject: Re: Upload Comma Deliminated File From IIS Directory and Append Results to Sql Table
From: stinger_60284-ga on 13 Feb 2003 07:51 PST
 
What programming language you are using?
I can give you an example how to import comma delimeted file into SQL
server using ASP.

Please confirm.
Subject: Re: Upload Comma Deliminated File From IIS Directory and Append Results to Sql Table
From: stinger_60284-ga on 13 Feb 2003 08:04 PST
 
Since you mentioned IIS, I assume you are using ASP.

Here is the code to get it:
...

set fso = server.CreateObject("scripting.FileSystemObject")
set f = fso.OpenTextFile("C:\YourPath\YourFileName", 1) ' 1: For Reading
do until f.AtEndOfStream
  sContent = f.ReadLine
  arrField = Split(sContent, ",")
   
  iRecNumber = arrField(0)
  sName      = arrField(1)
  
  sSQL = "INSERT INTO yourtableName(recordNumber,Name) " & _
         "VALUES(" & iRecNumber & ", '" & sName & "')"
  
  ' Execute your SQL statement here 
  ....
loop
f.Close

set f = nothing
set fso = nothing

...

Hope that helps.
Subject: Re: Upload Comma Deliminated File From IIS Directory and Append Results to Sql Table
From: pmclinn-ga on 13 Feb 2003 08:05 PST
 
VB and Javascript.
I'm asking for you to give me an example?
Subject: Re: Upload Comma Deliminated File From IIS Directory and Append Results to Sql Table
From: pmclinn-ga on 13 Feb 2003 08:10 PST
 
Would you finish this, looks good:

Sql Server name is ServerName
Table is TestingTable
user is SA
Pass is Test

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy