About DataAdapter

  • Thread starter Thread starter cherishman
  • Start date Start date
C

cherishman

When I use self-defined database, sometimes the dataadapter can't auto
create insertcommand, updatecommand and deletecommand, it just only create
selectcommand? But when I use these database such as Pub or Northwind in SQL
Server to create dataadapter, it can auto create updatecommand and
deletecommand. Why?
 
Cherishman,

You are probably talking about the dataadapterwizard (the name is in the
toolbox dataadapter I know).

That should work for your database created in MSDE, therefore can you give
more information.
Has every table a primary key by instance?

Cor
 
The table I created is in the SQL Server and doesn't have any primary key, I
don't want to set primary key, it can't work?
The table such as:
ID DT Columns1 Columns2
12 2002 12 13
I want to update the field "Columns2" to be 12.
 
Cherisman,

I am glad it was a good gues of my, it need an primary key to update or to
insert or to delete, that is all.

Cor
 
Thank you very much. I find it. but if I want to update some table without
primary key, what can I do?
thanks!
 
You can write the insert statement yourself. The real question is why you
would want a table without a primary key. Big No-No in database land. Even
if you just make a column for holding an integer value to give the row
uniqueness, you should do it.

Chris
 
Chris said:
You can write the insert statement yourself. The real question is why you
would want a table without a primary key. Big No-No in database land.
Even if you just make a column for holding an integer value to give the
row uniqueness, you should do it.

Chris

Yep,
Either there is some field or combination of fields is unique for every row
or you have no way of uniquely identifying a row.
Big no-no is an understatement!

You're trying to tell it to go update or delete a row, but without being
able to tell it which.
 
The SqlCommandBuilder class works on the select statement to obtain
updatecommands etc. only if you have used the right way to design
databases and if the select statement is "select * from table" because
only by selecting all the columns can the SQLCommandBuilder class obtain
reference for all the columns in the table and thus, autogenerate the
UpdateCommand, DeleteCommand etc.

with regards,


J.V.Ravichandran
- http://www.geocities.com/
jvravichandran
- http://www.411asp.net/func/search?
qry=Ravichandran+J.V.&cob=aspnetpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
display.asp?ID=P3966388&BN=999&PN=2
- Or, just search on "J.V.Ravichandran"
at http://www.Google.com
 
Back
Top