use of SqlDataAdapter with a table without Primary Key

  • Thread starter Thread starter DraguVaso
  • Start date Start date
D

DraguVaso

Hi,

I thought it isn't possible to use a SqlDataAdapter and a Databound grid
when there isn't a 'real' primary key on the table.
Although, is there a way to use it, and define somewhere in the
SqlDataAdapter my own primary key on the table?

I can't add a primary key to the table, so I guess that's the only way to
find a solution?

Any help would be really appreciated!

Thans a lot in advance,

Pieter
 
Hi,

Yes, dataadapter doesn't require a primary key. It is required just by the
wizards to generate insert/update/delete statements.
Also, dataadapter has nothing to do with binding to table.
 
You can create your own CRUD statements and avoid creating a magic key.
Simply write the INSERT, UPDATE and DELETE statement rather than relying on
the DataAdapter to automagically create one for you. As long as the SQL for
all four statements is correct, you are up and running.

--
Gregory A. Beamer
MVP; MCP: +I, SD, SE, DBA

*************************************************
Think outside the box!
*************************************************
 
Hehe I don't know anymore.
But it's great that it seems I'm able do do use it, although with writing
the upate statements myself, but that's no problem.

thanks a lot!
 
Pieter,

You was not telling that you wanted to update (and therefore my question).

Despite all others answers won't I not know what to update or to delete when
I don't have that key. (Inserting will go when there is an autoincrementkey
or a Guid used for the uniqueidentifier).

Just my thought,

Cor
 
Back
Top