473,326 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

use of SqlDataAdapter with a table without Primary Key

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
Jul 21 '05 #1
5 1446
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.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
www.rthand.com
SLODUG - Slovene Developer Users Group www.codezone-si.info

"DraguVaso" <pi**********@hotmail.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
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

Jul 21 '05 #2
Pieter,

From where do you have that idea?

Cor
Jul 21 '05 #3
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!
*************************************************
"DraguVaso" <pi**********@hotmail.com> wrote in message
news:#Z**************@TK2MSFTNGP09.phx.gbl...
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

Jul 21 '05 #4
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!

"Cor Ligthert" <no************@planet.nl> wrote in message
news:uJ**************@TK2MSFTNGP15.phx.gbl...
Pieter,

From where do you have that idea?

Cor

Jul 21 '05 #5
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
Jul 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: serge | last post by:
I ran into a table that is used a lot. Well less than 100,000 records. Maybe not a lot of records but i believe this table is used often. The table has 26 fields, 9 indexes but no Primary Key at...
0
by: Scott Ribe | last post by:
I've got a problem which I think may be a bug in Postgres, but I wonder if I'm missing something. Two tables, A & B have foreign key relations to each other. A 3rd table C, inherits from A. A...
6
by: goodstart123 | last post by:
For example, the following code works fine without SqlConnection. Any Answer to the question? string connectionString = "server=YourServer; uid=sa; pwd=YourPassword;...
5
by: DraguVaso | last post by:
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...
3
by: Alex Satrapa | last post by:
There's some mention in the (old!) documentation that constraints such as foreign keys won't include data from inheriting tables, eg: CREATE TABLE foo ( id SERIAL PRIMARY KEY ); CREATE TABLE...
6
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
3
by: Aaron | last post by:
Hi, The SqlDataAdapter.FillSchema method will automatically setup things like the primary keys, auto increment, etc based on the settings on the SQL Server. However, if you create a datatable...
2
by: Adrien Reboisson | last post by:
I'm trying to build a basic DB explorer using C# & Visual Studio 2005. I installed SQL Server 2005 Express, created a blank project, dropped a TreeView, a ListView and a DataGridView : DB objects...
1
by: niccolem | last post by:
HI: Can someone tell me HOW to insert a automatic number after my user inserts new data from text boxes into the dataset. I keep getting this error: Cannot insert the value NULL into column 'id',...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.