473,574 Members | 18,329 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Composite DataKeyField?

Is there any option we can use Composite DataKeyField in the DataList and
DataGrid?
Nov 18 '05 #1
4 4045
Are your strying to store more than one item of data in an item?
"Ismail Rajput" <hu************ @hotmail.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Is there any option we can use Composite DataKeyField in the DataList and
DataGrid?

Nov 18 '05 #2
As Composite Key concept says that there can
be more than one primary keys in a database table .

I want two different columns to store two primary keys and both of them make
composite key in my database

here we can have only one key
Dim productID As String =
MyDataList.Data Keys(MyDataList .SelectedItem.I temIndex)
CategoryID and ProductID together make composite key in my database.I faced
this problem when updating database record having composite key ,

i give you more detail
catid = 001 prodid =001
catid = 001 prodid =002
catid=002 prodid =001

If you look in primary keys , records are repeating but as composite they
are not .

if i update record with prodid then i will have two records updated .

"Felbrigg" <so*****@micros oft.com> wrote in message
news:Oq******** ******@TK2MSFTN GP10.phx.gbl...
Are your strying to store more than one item of data in an item?
"Ismail Rajput" <hu************ @hotmail.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Is there any option we can use Composite DataKeyField in the DataList and DataGrid?


Nov 18 '05 #3
Ismail,
If I understand correctly,you need to use a DataKeyField with both catid
and prodid information.
This may not be the straight forward way but here is how you can do this.
In your sql concatenate two of these columns which you want as composite
key separated by a charater say /.
For eg: in SQL Server
Select (catid + '/' + prodid) as catid_prodid,.. ........from
table_name
Set the DataKeyField as catid_prodid and do a split
to separate them before you make your UPDATE statement.
string[] compositecols=c ateidprodid.Spl it('/');
compositecols[0] and compositecols[1] will have catid and prodid
respectively.
There might be some other way which I am not sure.
Hope this helps.
Regards,
Marshal Antony
..NET Developer
http://www.dotnetmarshal.com
"Ismail Rajput" <hu************ @hotmail.com> wrote in message
news:u4******** ******@TK2MSFTN GP10.phx.gbl...
As Composite Key concept says that there can
be more than one primary keys in a database table .

I want two different columns to store two primary keys and both of them make composite key in my database

here we can have only one key
Dim productID As String =
MyDataList.Data Keys(MyDataList .SelectedItem.I temIndex)
CategoryID and ProductID together make composite key in my database.I faced this problem when updating database record having composite key ,

i give you more detail
catid = 001 prodid =001
catid = 001 prodid =002
catid=002 prodid =001

If you look in primary keys , records are repeating but as composite they
are not .

if i update record with prodid then i will have two records updated .

"Felbrigg" <so*****@micros oft.com> wrote in message
news:Oq******** ******@TK2MSFTN GP10.phx.gbl...
Are your strying to store more than one item of data in an item?
"Ismail Rajput" <hu************ @hotmail.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Is there any option we can use Composite DataKeyField in the DataList and DataGrid?



Nov 18 '05 #4
Marshal ,

Thanks and yes you got correctly as i wanted it to be understood
..I think this is the best possible way ,the way you told me to do this.
"Marshal Antony" <do***********@ yahoo.com> wrote in message
news:uj******** ******@TK2MSFTN GP10.phx.gbl...
Ismail,
If I understand correctly,you need to use a DataKeyField with both catid and prodid information.
This may not be the straight forward way but here is how you can do this.
In your sql concatenate two of these columns which you want as composite
key separated by a charater say /.
For eg: in SQL Server
Select (catid + '/' + prodid) as catid_prodid,.. ........from
table_name
Set the DataKeyField as catid_prodid and do a split to separate them before you make your UPDATE statement.
string[] compositecols=c ateidprodid.Spl it('/');
compositecols[0] and compositecols[1] will have catid and prodid
respectively.
There might be some other way which I am not sure.
Hope this helps.
Regards,
Marshal Antony
.NET Developer
http://www.dotnetmarshal.com
"Ismail Rajput" <hu************ @hotmail.com> wrote in message
news:u4******** ******@TK2MSFTN GP10.phx.gbl...
As Composite Key concept says that there can
be more than one primary keys in a database table .

I want two different columns to store two primary keys and both of them

make
composite key in my database

here we can have only one key
Dim productID As String =
MyDataList.Data Keys(MyDataList .SelectedItem.I temIndex)
CategoryID and ProductID together make composite key in my database.I

faced
this problem when updating database record having composite key ,

i give you more detail
catid = 001 prodid =001
catid = 001 prodid =002
catid=002 prodid =001

If you look in primary keys , records are repeating but as composite they are not .

if i update record with prodid then i will have two records updated .

"Felbrigg" <so*****@micros oft.com> wrote in message
news:Oq******** ******@TK2MSFTN GP10.phx.gbl...
Are your strying to store more than one item of data in an item?
"Ismail Rajput" <hu************ @hotmail.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
> Is there any option we can use Composite DataKeyField in the
DataList and
> DataGrid?
>
>



Nov 18 '05 #5

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

Similar topics

1
1499
by: rufus | last post by:
Hi, I was wondering how a DataGrid can handle a DataSet with a composite key. How would I update 1 row in a database having a composite key? A possible solution would be to concatenate my composite key in my sql statement and then use the split function to separate again when I update. To me this seems too complicated for its own good. ...
0
1963
by: A frustrated developer | last post by:
I would like to find a specific row on web datagrid, locate its pageindex and itemindex, then highlight to the specific row I found. I know its datakeyfield value, is there anyway we could search by its datakeyfield and return the location of the item on web datagrid? Thanks a bunch -:)
0
1122
by: A frustrated developer | last post by:
I would like to find a specific row on web datagrid, then highlight the row by its pageindex and itemindex on that page. I know its datakeyfield, is there a way to find the row by its datakeyfield on web datagrid? Thanks a bunch -:)
0
1259
by: A frustrated developer | last post by:
I would like to find a specific row on the web datagrid, then highlight the row by its pageindex and itemindex on that page. I know its datakeyfield, is there a way to find the row by its datakeyfield on web datagrid? Thanks a bunch -:)
0
2392
by: AshifToday | last post by:
this was my and my frineds little project in earlier classes, the program seperates the composite and prime numbers in two sections of the screen ===================== /* This program has been made by A & A Group. Muhammad Ali: Roll # 1462 Class A-2 , B.Sc.(Hons.) in C.S.
18
12636
by: Thomas A. Anderson | last post by:
I am a bit confused in creating a composite primary key. I have three table with two of the tables containing primary keys. I have two of the tables (each with a primary key) having one to many relations with the table containing no primary key. Do I just create two primary keys on the table that does not contain any primary key for this to...
0
1184
by: sramruttun | last post by:
hi In my database I have a table in which 3 fields make up the primary key. I use a datagrid to add, edit/update and delete entries of that table. To facilitate this work we often use the datakeyfield property to allow us to get the primary key of the row where the edit/delete is being done. This works well when 1 field is the p.key. How...
0
1396
by: Adam Knight | last post by:
I have a datagrid like so: <asp:DataGrid ID="dgSubAreas" Runat="server" AutoGenerateColumns="False" DataKeyField="" DataSource='<%# Container.DataItem.Row.GetChildRows("relSubAreas") %>'> Its data source is the result of a table relation created like this: ds.Relations.Add("relSubAreas", ds.Tables("Areas").Columns("area_id"),
14
5015
by: dave.dolan | last post by:
Basically I'd like to implement the composite design pattern with leaves that are either of reference or value types, but even using generics I can't seem to avoid boxing (using ArrayList or Object) Is this even possible, or is the composite pattern doomed to use the System.Object type forever? I have tried using interfaces with generics,...
0
7817
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...
0
8081
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8258
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8119
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...
0
6482
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...
0
3759
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3771
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2254
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
1
1359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.