473,399 Members | 2,278 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,399 software developers and data experts.

find the index of row in datatable,mysql

hi,

i want to know the index of row( i know the primary key column value, based on that i want to know the index of that row in data table)

here is my code i tried:
but it's giving error as:table doesn't have a primary key. c#

But my datatable in Mysql database is having primary key column.
Expand|Select|Wrap|Line Numbers
  1. using (MySqlConnection con = new MySqlConnection(ConnectionString))
  2.                 {
  3.                     String query = "select * from customer";
  4.                     MySqlCommand command = new MySqlCommand(query, con);
  5.                     MySqlDataAdapter da = new MySqlDataAdapter(query, con);
  6.                     da.Fill(dt1);
  7.                     totalRowsInDB = dt1.Rows.Count;
  8.                     Startindex = dt1.Rows.IndexOf(dt1.Rows.Find(startNo));
  9.                     Endindex = dt1.Rows.IndexOf(dt1.Rows.Find(endNo));
  10.                     con.Open();
here startNo=1002 and endNo=1005
which i have in database primary key values
Mar 1 '14 #1
1 1823
Luuk
1,047 Expert 1GB
use:
Expand|Select|Wrap|Line Numbers
  1. select @a:=@a+1 ROWNUM, * from .....
you can reset '@a' using:
Expand|Select|Wrap|Line Numbers
  1. set @a=0
Mar 1 '14 #2

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

Similar topics

1
by: mudge | last post by:
Hello, I have a mysql table. Two columns in the table are used to pull out stories from the table. One of the columns stands for categories of the stories, and the other column is the primary...
2
by: Sean Berry | last post by:
Given myList = what is the easiest way to find out what index 'dog' is at?
11
by: ike | last post by:
Could you please give your opinion on the portability of this code? /* -------- begin findindex.c -------- */ struct Foo { int junk0; }; struct Bar { int junk1; struct Foo foo; int junk2; }; ...
0
by: tomzam | last post by:
I'm trying to get mysql working on Fedora Core 4. Actually trying to start the program mysqld without fatal errors. I posted this message first on the linux misc group - but no luck so far. Maybe...
10
by: cmrhema | last post by:
hello I am working in asp.net and C# I am selecting multiple items in a list box. Now I want a count of the seleted items also the index of the selected item I browsed and found something...
2
by: GS | last post by:
I want to create a dropdownlistbox in my windows form with name value pair. but I need to initialize its initial selected value to a value from database for the record. I was going to just use...
1
by: Lorna | last post by:
I have a table on a form containing 2 columns - size type and size. Depending on the size type (Mens, womens, Youth) I want to change the set of sizes available (in an option box). I have been able...
5
by: zcabeli | last post by:
Hello, how can i find the index of an existing element in a list ? thanks,
4
by: raylopez99 | last post by:
I would like to know if there's a quick "Linq" way to find the index of an array having a particular value. I can do this the long way by sequential iteration, but would like to know if there's a...
0
by: NewBornDBA | last post by:
I am a sql server DBA. I don't know anything about MySQL. The problem is that "/var/lib/MySQL" maxed out disk space and caused MySQL to crash. I was able to move all the files to /home and I was also...
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
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
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,...
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
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,...
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...
0
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...
0
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,...
0
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...

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.