multiple record inserts

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jim

    multiple record inserts

    Using aspx and vb with sql2005 server.
    I have an insert form/query that will insert a record. What I want to do is
    on the page have a dropdown list with numbers. From the dropdown list, the
    user will select how many records to insert the date (each insert is a
    seperate record).

    For example, if a user has 20 parts to enter, instead of entering the same
    information 20 times, they can select the number 20 from the dropdown list
    and then fillout the information in the form and when the "Insert" button is
    clicked, the sql insert query will run 20 times.

    Is this possible? If so, can you point me to a place that either has an
    example or talks about it?

    Thanks.


  • sloan

    #2
    Re: multiple record inserts



    One idea.

    Create a strong dataset.

    EmployeeDS

    with 1 table.

    Employee (table)

    with some columns

    EmployeeID, LastName, FirstName
    .............

    After your user selects "I want to insert 10 new employees"....
    on the code behind, create a "dummy" EmployeeDS, and then bind your GridView
    or Repeater to it.


    dim ds as EmployeeDS = new EmployeeDS
    --excuse any syntax errors with my vb.net skillzz
    For i as int32 = 0 to 9

    EmployeeDS.Empl oyeeRow newRow = ds.Employee.New EmployeeRow

    newRow.EmpID = i '' obviously this won't be the actual empid, but
    will give you some kind of uniqueidentifie r until you ship it to the
    database

    ds.Employee.Add NewEmployeeRow = newRow

    next i

    Then bind your GridView to
    gv1.DataSource = ds.Employee
    gv1.DataBind


    That'll give you the entries you need.


    THEN!!

    You can dual use the EmployeeDS....


    and insert all 10 new employees into the db in a single shot.

    Sweet!






    "Jim" <stopspam@redmo nd.comwrote in message
    news:%234jda$eW IHA.4140@TK2MSF TNGP04.phx.gbl. ..
    Using aspx and vb with sql2005 server.
    I have an insert form/query that will insert a record. What I want to do
    is on the page have a dropdown list with numbers. From the dropdown list,
    the user will select how many records to insert the date (each insert is a
    seperate record).
    >
    For example, if a user has 20 parts to enter, instead of entering the same
    information 20 times, they can select the number 20 from the dropdown list
    and then fillout the information in the form and when the "Insert" button
    is clicked, the sql insert query will run 20 times.
    >
    Is this possible? If so, can you point me to a place that either has an
    example or talks about it?
    >
    Thanks.
    >

    Comment

    Working...