sqldataadpater wizard code

  • Thread starter Thread starter Mark Kurten
  • Start date Start date
M

Mark Kurten

i used the sqldataadapter wizard to generate the following insert statement
"
("INSERT INTO Company(Code, Name, Address1, Address2, Address3, Address4,
BEGINDT, " & _

"BegCheck#, EndCheck#, CancelDate, InsType, STATE) VALUES (@Code, @Name,
@Address" & _

"1, @Address2, @Address3, @Address4, @BEGINDT, @BegCheck#, @EndCheck#,
@CancelDat" & _

"e, @InsType, @STATE); SELECT Code, Name, Address1, Address2, Address3,
Address4," & _

" BEGINDT, BegCheck#, EndCheck#, CancelDate, InsType, STATE FROM Company
WHERE (C" & _

"ode = @Code)")

"

My question is, why is there a select statement included with the insert
statement?

thanks.
 
When you are configuring your adapter, you have the Refresh DataSet option
on which generates this for you...it helps to keep things like Identity
values in Sync and the like.

Just reconfigure your adatper and when you get to the SQL Builder section,
go to Advanced OPtions and uncheck Refresh DataSet (it's the one on the
bottom) if you don't want this in there.

HTH,

Bill
 
Thanks for Bill's quick response.

Hi Mark,

Thank you for posting in the community!

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to know why there is a SELECT
statement follows the INSERT statement in the SqlDataAdapter wizard
generated code. If there is any misunderstanding, please feel free to let
me know.

Just as Bill mentioned, if you have selected Refresh DataSet in the
Advanced Options, it will add a SELECT statement to the INSERT command. We
need to refresh the DataSet because sometimes the inserted value record is
slight different from the value in the DataSet. For example, there is an
auto-increment column in the DataSet. As the auto-increment value is auto
generated in the database table, the real inserted value might be different
from the value originally generated in the DataSet. So to keep the data in
the DataSet up-to-date, we need to synchronize them. Then an SELECT
statement is added.

Does this answer your question? If anything is unclear, please feel free to
reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
thanks for the help, I just wanted to make sure that the select statement
wasn't a required part..
 
Back
Top