By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,379 Members | 1,357 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,379 IT Pros & Developers. It's quick & easy.

Add a list stored in a text file to a SQL Server 2005 database

P: 57
Hi I am coding an ASP .Net project in C# and am using connection strings to connect to a Microsoft SQL Server 2005 database, and the project involves tracking student attendance records at a university.

I have a table for each class in the uni, and the only field is StudentNumber. Whenever an admin wants to add a new module, a new table is created, and then whenever he wants to add students to that class table he has to currently add each student number to the table individually.

I am looking for a way so that if an admin has a list of student numbers in a text file, he can just submit this text file to my application and the C# will parse this text file and add each individual student number to this table.

Does anybody know any SQL commands that will let me do this or know how I can get the application to ask the user to submit a file?
Apr 21 '08 #1
Share this Question
Share on Google+
1 Reply


ck9663
Expert 2.5K+
P: 2,878
Hi I am coding an ASP .Net project in C# and am using connection strings to connect to a Microsoft SQL Server 2005 database, and the project involves tracking student attendance records at a university.

I have a table for each class in the uni, and the only field is StudentNumber. Whenever an admin wants to add a new module, a new table is created, and then whenever he wants to add students to that class table he has to currently add each student number to the table individually.

I am looking for a way so that if an admin has a list of student numbers in a text file, he can just submit this text file to my application and the C# will parse this text file and add each individual student number to this table.

Does anybody know any SQL commands that will let me do this or know how I can get the application to ask the user to submit a file?

option 1:
1. Ask for the file name (with path) as parameter in an upload utility that you can create. (catch: the text file has to be on a drive that the server can see)
2. Use BULK INSERT to convert the text file into table.
3. Use T-SQL to update all other table.

option 2:
1. Ask for the file name (with path) as parameter in an upload utility that you can create.
2. Using C#, parse the text file, assuming one row = one record.
3. Do an INSERT for ever row on your text file.

-- CK
Apr 21 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.