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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • moorcroft
    New Member
    • Mar 2008
    • 57

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

    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?
  • Mr Gray
    New Member
    • Apr 2008
    • 47

    #2
    You can use one of these asp server controls:

    Code:
    <asp:FileUpload ID="fileStudentList" runat="server" />
    then the file you upload you can search through the list of numbers and maybe turn them into an array:

    Code:
    file.contents.Split(",");
    the last bit of code is only to demonstrate what you could do it is not actually correct.

    Best bet is search for the fileupload asp control and learn how that works then learn how to manipulate the contents of that file using the String class and also as another point look into the System.IO namespace and learn what that can do for you as those are the parts I would use to do something like what you are suggesting.

    Comment

    • moorcroft
      New Member
      • Mar 2008
      • 57

      #3
      cheers that sounds like what I need, will look into it now

      Comment

      Working...