|
-
Jun 15th, 2002, 04:31 PM
#1
Thread Starter
Dazed Member
SqlCommand and DataAdapter?
Does anyone know how many overloaded constructors the DataAdapter has? I know one of them takes an string representing an sql statment and a connection string. But does one of them take a SqlCommand object and a connection string?
I am just reading a snippet from a book which says the following:
"When using a DataAdpater with a DataSet, Command objects are used to return and modify data at the source through the DataAdapter object's SelectCommand, InsertCommand, UpdataCommand, and DeleteCommand properties."
So would i have to set one of the previous properties of the DataAdapter to a SqlCommmand object? Im not quite sure. This crappy book fails to give a code snippet. Thanks.....
Last edited by Dilenger4; Jun 15th, 2002 at 09:20 PM.
-
Jun 15th, 2002, 08:46 PM
#2
New Member
re:
i think... what you want to know is if you can use any other sql commands other than the four preset by the adapter...
yes you can, you add a sqlcommand object to the form, and set the connection to use.
-
Jun 15th, 2002, 09:27 PM
#3
Thread Starter
Dazed Member
Posted by TLawson
i think... what you want to know is if you can use any other sql commands other than the four preset by the adapter...
Thanks for replying TLawson but i want to know specifically if a SqlDataAdapter can take a SqlCommand object in place of a string that holds a SQL string. The excerpt that i posted isn't really that clear to me
-
Jun 16th, 2002, 12:53 AM
#4
Thread Starter
Dazed Member
It seems that a SqlDataAdapter can either be created with a SQL string and a Connection object.
Code:
objDA = New SqlDataAdapter(strSQL,strConn)
or the SelectCommand property can be used to retrieve data from the data soure like this.
Code:
objDA.Select(strSQL)
Now what are the different combinations that i can have? Can i just provide the connection string to the SqlDataAdapter constructor and a SQL string to the SqlDataAdapter's Select command. Then fill the DataSet using the SqlDataAdapter's Fill method? Or do i pass in bolth the SQL string and the connection string to the constructor and invoke the Select method with empty arguements?
-
Jun 16th, 2002, 04:41 AM
#5
New Member
hmm, good question, looking over what i have coded since begining .dot, it seems i use whatever seems to fit the occasion. i usally look to dataadapters and datasets to do my binding and provide visual info to the user, and commands to perform actuall changes to the database, usally by creating one sqlcommand object with a connection string, but no command text, and then declaring my command text on the fly to suit my needs, i havnt been programming but for a little it now, and may not be doinging this the "standard" way
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|