Results 1 to 5 of 5

Thread: SqlCommand and DataAdapter?

  1. #1

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Question 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.....

  2. #2
    New Member
    Join Date
    Jun 2002
    Posts
    12

    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.

  3. #3

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    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

  4. #4

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    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?

  5. #5
    New Member
    Join Date
    Jun 2002
    Posts
    12
    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
  •  



Click Here to Expand Forum to Full Width