473,387 Members | 1,540 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,387 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
Nov 21 '05 #1
5 3999
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

Nov 21 '05 #2
Pieter,

From where do you have that idea?

Cor
Nov 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

Nov 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

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

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

Similar topics

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...
14
by: serge | last post by:
I have a scenario where two tables are in a One-to-Many relationship and I need to move the data from the Many table to the One table so that it becomes a One-to-One relationship. I need to...
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;...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.