471,852 Members | 913 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Composite DataKeyField?

Is there any option we can use Composite DataKeyField in the DataList and
DataGrid?
Nov 18 '05 #1
4 3971
Are your strying to store more than one item of data in an item?
"Ismail Rajput" <hu************@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.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.DataKeys(MyDataList.SelectedItem.ItemIn dex)
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*****@microsoft.com> wrote in message
news:Oq**************@TK2MSFTNGP10.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****************@tk2msftngp13.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=cateidprodid.Split('/');
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**************@TK2MSFTNGP10.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.DataKeys(MyDataList.SelectedItem.ItemIn dex)
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*****@microsoft.com> wrote in message
news:Oq**************@TK2MSFTNGP10.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****************@tk2msftngp13.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**************@TK2MSFTNGP10.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=cateidprodid.Split('/');
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**************@TK2MSFTNGP10.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.DataKeys(MyDataList.SelectedItem.ItemIn dex)
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*****@microsoft.com> wrote in message
news:Oq**************@TK2MSFTNGP10.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****************@tk2msftngp13.phx.gbl...
> Is there any option we can use Composite DataKeyField in the
DataList and
> DataGrid?
>
>



Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by rufus | last post: by
reply views Thread by A frustrated developer | last post: by
reply views Thread by AshifToday | last post: by
18 posts views Thread by Thomas A. Anderson | last post: by
reply views Thread by sramruttun | last post: by
reply views Thread by Adam Knight | last post: by
NeoPa
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by
aboka
reply views Thread by aboka | last post: by

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.