Hi,
"Rich" <Ri**@discussio ns.microsoft.co mwrote in message
news:80******** *************** ***********@mic rosoft.com...
>I believe the answer to my question is that you can use the
dataAdapter.Upd ate method with dataAdapter.Ins ertCommand and
dataAdapter.Upd ate command, but you can only use dataAdapter.Fil l with the
dataAdapter.Sel ectCommand.
DataAdapter.Upd ate(DataTable) will use UpdateCommand for each row that is
modified, InsertCommand for each new row and DeleteCommand for each deleted
row.
DataAdapter.Fil l(DataTable) will use the SelectCommand.
Notice that these Update, Insert, Delete Command's are not supposed to be
used like you do. Their SQL queries should include parameters which are
linked to the field (column) names in the DataTable and you should not call
ExecuteNonQuery on them.
If you want to execute a query like yours, then use a SqlCommand instead,
eg. :
Dim cmd As New SqlCommand()
cmd.Connection = conn
cmd.CommandType = Command.Text
cmd.CommandText = "insert Into tbl1 Select * from tbl2"
cmd.ExecuteNonQ uery()
HTH,
Greetings
>
Any additional comments appreciated.
"Rich" wrote:
>What is the diffeence bewtween a dataAdapter.Ins ertCommand and
dataAdapter.Se lectCommand (and dataAdapter.Upd ateCommand for that
matter)?
Dim da As SqlDataAdapter
conn.Open
da.SelectComma nd = New SqlCommand
da.SelectComma nd.Connectoin = conn
da.SelectComma nd.CommandType = Command.Text
da.SelectComma nd.CommandText = "insert Into tbl1 Select * from tbl2"
da.SelectComma nd.ExecuteNonQu ery
Or
Dim da As SqlDataAdapter
conn.Open
da.InsertComma nd = New SqlCommand
da.InsertComma nd.Connectoin = conn
da.InsertComma nd.CommandType = Command.Text
da.InsertComma nd.CommandText = "insert Into tbl1 Select * from tbl2"
da.InsertComma nd.ExecuteNonQu ery
Is there any differece between these 2 dataAdapters? It looks to me like
they both perform the same operation.
Thanks,
Rich