emaduddeen
Well-known member
- Joined
- May 5, 2010
- Messages
- 171
- Location
- Lowell, MA & Occasionally Indonesia
- Programming Experience
- Beginner
Hi Everyone,
Just wondering if using "New" repeatedly will eventually use of memory or this is not a very efficient way to write code.
Here's an example I did with a command builder:
I'm just wondering if the command builder can be created once and then just tell it to get the update or insert command because this sub procedure get called a lot.
Thanks.
Truly,
Emad
Just wondering if using "New" repeatedly will eventually use of memory or this is not a very efficient way to write code.
Here's an example I did with a command builder:
VB.NET:
' Add a new blank row into the Data Set if the user chose to Insert.
'-------------------------------------------------------------------
If booleanAddNew Then
objDataSetParentDetails.Tables("Parent Details").Rows.Add(objDataRowParentDetails)
End If
' Create an instance of the command builder.
'-------------------------------------------
objCommandBuilderParentDetails = New SqlCommandBuilder(objDataAdapterParentDetails)
If booleanAddNew Then
' Have the command builder create an Insert SQL command.
'-------------------------------------------------------
objDataAdapterParentDetails.InsertCommand = objCommandBuilderParentDetails.GetInsertCommand
Else
' Have the command builder create an update SQL command.
'-------------------------------------------------------
objDataAdapterParentDetails.UpdateCommand = objCommandBuilderParentDetails.GetUpdateCommand
End If
' Perform the update SQL command; then close the connection.
'-----------------------------------------------------------
objDataAdapterParentDetails.Update(objDataSetParentDetails, "Parent Details")
objDataSetParentDetails.Tables("Parent Details").AcceptChanges()
I'm just wondering if the command builder can be created once and then just tell it to get the update or insert command because this sub procedure get called a lot.
Thanks.
Truly,
Emad