stumped

  • That would be dynamic sql.... Preffer the proc approach.

  • why dyniamic? I concat at client side, No sp call  


    * Noel

  • Starting to sound like another moo point here... He must know what's best for his system.

    But I wouldn't do that just to be sure there's no possibily of injection. If the page is not used often, 10-15 calls in a row is not gonna kill the network/server.

  • there will be injection if strong typing is not used to gather the values and yes it is true that when the activity is not big it is not going to hurt but again only he knows

    BTW: that is the FASTEST method to insert multiple records

     


    * Noel

  • He is using CommandType.StoredProcedure.

    cmdSave = New SqlCommand("Test", GlobalConnection)

    cmdSave.CommandType = CommandType.StoredProcedure

    parmReturnValue = cmdSave.Parameters.Add("RETURN_VALUE", SqlDbType.Int)

    parmReturnValue.Direction = ParameterDirection.ReturnValue

    cmdSave.Parameters.Add("@UserID", lvUserID)

    cmdSave.Parameters.Add("@test", TextBox1.Text)

    GlobalConnection.Open()

    cmdSave.ExecuteNonQuery()

    GlobalConnection.Close()

    To do it this way you do need to call the method once for each text box. Test for it however you want.

    Remi is suggesting you prepare a String with the insert statements, or procedure calls in it, then executing it at once.

     

    SqlConnection myConnection = new SqlConnection(

        "server=(local)\NetSDK;database=pubs;Integrated Security=SSPI");

    SqlCommand myCommand = new SqlCommand(

        "Exec dbo.SpName 1, 3, 67

    Exec dbo.SpName 2, 4, 56

    Exec dbo.SpName 3, 2, 43

    ", myConnection);

    myCommand.Connection.Open();

    myCommand.ExecuteNonQuery();

    myCommand.Connection.Close();

    Not Tested!!

  • How about exporting to text file then using bulk insert .

  • Now your thinking outside the box.

    Not sure how big the box is though.

  • Hey we seem to be throwing ideas out there...

    Why not xml??

  • Assuming the data is in a dataset (or datatable) it is still the FASTEST way


    * Noel

  • I know... Just throwing ideas around.

Viewing 10 posts - 16 through 24 (of 24 total)

You must be logged in to reply to this topic. Login to reply