473,757 Members | 2,083 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1477
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**********@h otmail.com> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l...
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**********@h otmail.com> wrote in message
news:#Z******** ******@TK2MSFTN GP09.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******** ******@TK2MSFTN GP15.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 autoincrementke y
or a Guid used for the uniqueidentifie r).

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
10564
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 all! There are no table relationships defined in this database, no Natural keys, only Surrogate keys in the database. 1- Maybe an odd question but is it normal to have 1/3 of the table's fields as indexes? Is this a valid question or it really
0
1418
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 stored procedure updates a row in C, adds a row each in B & C. I get an integrity violation. All the foreign keys are deferrable, and the stored procedure is called from within a transaction with constraints deferred. (And the foreign keys do refer to...
6
4314
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; database=ProgASPDotNetBugs"; // get records from the Bugs table string commandString = "Select BugID, Description from Bugs";
5
4007
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 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?
3
5384
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 bar ( attribute integer NOT NULL ) INHERITS (foo);
6
4848
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 SalesManName AT Alan Time
3
5206
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 using the SQL statement that joins together data from multiple data tables, then FillSchema does not work (as much? at all??). For example, if I use the following query: SELECT Material.*, Color.Color AS Color
2
16894
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 (Databases, tables, SPs, and so on) are displayed in the tree, table colums definitions in the list and I want to display the selected table content in the DataGridView. So far so good. Currently, I succedded in loading the treeview and the...
1
1901
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', table; column does not allow nulls. INSERT fails. (ID IS MY KEY) I can update & delete fine, but when I try to insert, I cannot figure out how to get the primary key inserted. I'm new @ this & I think I've confused myself.... THANK YOU Dim...
0
9487
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9735
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8736
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7285
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6556
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5324
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3828
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3395
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2697
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.