473,326 Members | 2,337 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.

finding a specific row of a dataset

Hi, i'm wondering if anyone can help me,

i'm using a dataset filled with several rows of information from an sql table - demotable

demotable consists of
demotableid, 1,2,3,4,5


an e.commandargument is getting the row of a gridview fromwhich this table is display.

on e.commandargument (the primary key), i'd like to transfer the contains of the row matching this primary key to a datarow, so that i can perform some operations on the data. I'm using datasets and datarows for this trial, if anyone could give me an answer using these that would be great!, so far i've tried this
dr = ds.Tables("demotable").Rows.Find(e.commandargument )

but it says there is no primary key set.


:-(


vb.net
Dec 18 '07 #1
1 975
nateraaaa
663 Expert 512MB
You are on the right track but you need to create a primary key before you can use Rows.Find.

// Setting the Primary Key
Expand|Select|Wrap|Line Numbers
  1. DataColumn colPk = new DataColumn();
  2. colPk = ds.Tables["demotable"].Columns["demotableid"];
  3. ds.Tables["demotable"].PrimaryKey = colPk; 
After you add this code you should be able to use the Rows.Find method on your primary key value.

Nathan
Dec 18 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: David | last post by:
Hello, I use the VS .NET 2003. Say I have a Windows form (with C# code, of course) which is connected to a database to one table. I can browse through the records, but I don't know how to...
3
by: Wilson Wu | last post by:
Hi, How can I find the field value in the dataset and then assign one of the field value to a variable ? Thanks Wilson
0
by: Doug | last post by:
I've got a strongly-typed dataset with 2 related tables in it ("Staff" and "Roles"). I want to make a change to the parent Staff row and also to its child Role row. I'm having difficulty figuring...
3
by: coleenholley | last post by:
I need to know how to get a specific row/cell of data to post as a session variable - like I would with an ASP.Net table: Dim ld_sum_tot_cty_tax As Doubl Session("wa_tot_gal") =...
2
by: Lior | last post by:
Hi, I have an ASP.NET website that crashes under heavy load. I use a SQL Server DB. I get around 5500 hits per day. I keep getting the timeout expieried connection pool error. Sometimes it even...
5
by: Usman Ghani | last post by:
HI All, I used to drag drop Datasets and adapters etc, and once dataset is filled, I can count rows in a dataset as datasetname.tablename.rows.count I started doing all this programatically,...
0
by: Leeor Chernov | last post by:
Hi , I am using the method: DSSap.ReadXml( XmlPath,XmlReadMode.InferSchema ); And as I expected I get an error when the xml does not matching my DataSet that contains already a schema , The...
3
by: Newbie | last post by:
Could someone please tell me how or if the following is possible. I have created a small test database and have opened one connection, one DataAdapter, and one Dataset for it in my vb.net...
3
by: DavidB | last post by:
New to .net....sorry if this seems repetitive I have a dataset ordered by date (SQLDataAdapter SelectCommand uses Order By) and want to find a record by a UniqueID(Identity Column). Then I want...
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...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.