June 30, 2005 at 1:48 pm
That would be dynamic sql.... Preffer the proc approach.
June 30, 2005 at 1:51 pm
why dyniamic? I concat at client side, No sp call
* Noel
June 30, 2005 at 1:54 pm
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.
June 30, 2005 at 2:01 pm
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
June 30, 2005 at 2:04 pm
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!!
June 30, 2005 at 2:07 pm
How about exporting to text file then using bulk insert .
June 30, 2005 at 2:12 pm
Now your thinking outside the box.
Not sure how big the box is though.
June 30, 2005 at 2:14 pm
Hey we seem to be throwing ideas out there...
Why not xml??
June 30, 2005 at 3:08 pm
Assuming the data is in a dataset (or datatable) it is still the FASTEST way
* Noel
June 30, 2005 at 5:34 pm
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