473,385 Members | 1,912 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,385 software developers and data experts.

How to get record number from original table



Hi

Any idea on how to get a row number from the original table? We do a
query and get a result. The row number from the result is different
from the rownumber of the table the result originated from. I need the
record number from the original tabel. How do you get THAT number?

Please help,

Regards, Martin
Nov 21 '05 #1
12 3012
Martin Heuckeroth <ni**@nospam.invalid> wrote in
news:ot********************************@4ax.com:
Any idea on how to get a row number from the original table? We do a
query and get a result. The row number from the result is different
from the rownumber of the table the result originated from. I need the
record number from the original tabel. How do you get THAT number?


Did you do a SELECT COUNT(*)? Or did you do a SELECT COUNT(FIELDNAME)? If
you did the second, it returns non-null values which maybe why your row
counts are inaccurate:

http://msdn.microsoft.com/library/de...l=/library/en-
us/tsqlref/ts_ca-co_5790.asp

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 21 '05 #2
What are you trying to do?

One of the basic rules of relational databases is that the order of rows is
not important. If you need to identify a particular row you should be using
keys and unique indexes.

hth
Richard
Nov 21 '05 #3
VJ
I think Martin is looking for something like RowIndex the hexadecimal value
that is available in Oracle. Are you trying to delete duplicate rows created
by mistake? what are you trying do ? If you are trying to delete dup rows i
have queries that can do that.. let me know .... but if you are looking to
use in program I am not aware of it...

VJ

"Martin Heuckeroth" <ni**@nospam.invalid> wrote in message
news:ot********************************@4ax.com...


Hi

Any idea on how to get a row number from the original table? We do a
query and get a result. The row number from the result is different
from the rownumber of the table the result originated from. I need the
record number from the original tabel. How do you get THAT number?

Please help,

Regards, Martin

Nov 21 '05 #4
We are looking for a way to determine the rownumber of the record in
the original database. Records are renumbered in the relation and we
want to edit/modify the original record in the original table.
Therefore we think we need the recordnumber of the original record in
the original table.

Here some code we brew... We need for nRecord in the 2nd line the
rownumber of the original table where nRecord NOW returns the
recordnumber of the relation.

Function SaveItem()
Dim nRecord As Integer = Me.BindingContext(DsGroup_News1,
"NewsGroup.NewsGroupNews").Position
Console.WriteLine(nRecord)
Dim nRow As DataRow = DsGroup_News1.News.Rows(nRecord)
Dim lDelete As Boolean =
DsGroup_News1.Tables("News").Rows(nRecord)("Record _Delete")
StatusBarSync(2)
If (nRow.HasVersion(DataRowVersion.Proposed) = True) Then
Me.DsGroup_News1.Tables("News").Rows(nRecord)("Vie wed") +=
1

Me.DsGroup_News1.Tables("News").Rows(nRecord)("Dat e_Modify") = Now()
Me.DsGroup_News1.Tables("News").Rows(nRecord)("Ver sion") =
Microsoft.VisualBasic.Right(StatusBarPanel_Version .Text, 8)
If lDelete = True Then

Me.DsGroup_News1.Tables("News").Rows(nRecord)("Dat e_Delete") = Now()
End If
On Sun, 5 Sep 2004 16:16:28 -0500, "VJ" <vi********@yahoo.com> wrote:
I think Martin is looking for something like RowIndex the hexadecimal value
that is available in Oracle. Are you trying to delete duplicate rows created
by mistake? what are you trying do ? If you are trying to delete dup rows i
have queries that can do that.. let me know .... but if you are looking to
use in program I am not aware of it...

VJ

"Martin Heuckeroth" <ni**@nospam.invalid> wrote in message
news:ot********************************@4ax.com.. .


Hi

Any idea on how to get a row number from the original table? We do a
query and get a result. The row number from the result is different
from the rownumber of the table the result originated from. I need the
record number from the original tabel. How do you get THAT number?

Please help,

Regards, Martin


Nov 21 '05 #5
Martin,
You haven't said what sort of DB you are connecting to but in any case one
of the rules of relational databases is that rows are un-ordered.
Your table should have a primary key and you could sort by it. You can't
rely on a record number.

Doug

"Martin Heuckeroth" <ni**@nospam.invalid> wrote in message
news:ot********************************@4ax.com...


Hi

Any idea on how to get a row number from the original table? We do a
query and get a result. The row number from the result is different
from the rownumber of the table the result originated from. I need the
record number from the original tabel. How do you get THAT number?

Please help,

Regards, Martin

Nov 21 '05 #6

"Doug Bell" <dug@bigpond> wrote in message
news:uY*************@TK2MSFTNGP09.phx.gbl...
Martin,
You haven't said what sort of DB you are connecting to but in any case one
of the rules of relational databases is that rows are un-ordered.
Your table should have a primary key and you could sort by it. You can't
rely on a record number.

Doug

"Martin Heuckeroth" <ni**@nospam.invalid> wrote in message
news:ot********************************@4ax.com...


Hi

Any idea on how to get a row number from the original table? We do a
query and get a result. The row number from the result is different
from the rownumber of the table the result originated from. I need the
record number from the original tabel. How do you get THAT number?

Please help,

Regards, Martin


Nov 21 '05 #7
Martin Heuckeroth <ni**@nospam.invalid> wrote in
news:pn********************************@4ax.com:
We are looking for a way to determine the rownumber of the record in
the original database.


There is no such thing as a row number in a relational database.

If you need some sort of identifier... add an integer identity (autonumber)
column to the original table. You can track changes via the identity field.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 21 '05 #8
In modern relational databases their is no such thing as "physical record
number" of any record. Every thing is relational.

The only way to identify a particular record in a sure shot way is the
primary key of the table.

Gajendra
-------------------------------------
"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn***************************@140.99.99.130.. .
Martin Heuckeroth <ni**@nospam.invalid> wrote in
news:pn********************************@4ax.com:
We are looking for a way to determine the rownumber of the record in
the original database.
There is no such thing as a row number in a relational database.

If you need some sort of identifier... add an integer identity

(autonumber) column to the original table. You can track changes via the identity field.
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Nov 21 '05 #9
O.k what you've posted here is a bunch of dataset related code.

I dont really see what this code has to do with your DBMS explaination. If
the data in this dataset is filled from a table then why not put a Primary
key (MessageId) on the table to use when referring back to the DBMS source
table if thats what your trying to do.

It's would also be a good idea to check out the With keyword, it would help
clean your code up quite a lot and is more performant in places like this.

hth
Richard


"Martin Heuckeroth" <ni**@nospam.invalid> wrote in message
news:pn********************************@4ax.com...
We are looking for a way to determine the rownumber of the record in
the original database. Records are renumbered in the relation and we
want to edit/modify the original record in the original table.
Therefore we think we need the recordnumber of the original record in
the original table.

Here some code we brew... We need for nRecord in the 2nd line the
rownumber of the original table where nRecord NOW returns the
recordnumber of the relation.

Function SaveItem()
Dim nRecord As Integer = Me.BindingContext(DsGroup_News1,
"NewsGroup.NewsGroupNews").Position
Console.WriteLine(nRecord)
Dim nRow As DataRow = DsGroup_News1.News.Rows(nRecord)
Dim lDelete As Boolean =
DsGroup_News1.Tables("News").Rows(nRecord)("Record _Delete")
StatusBarSync(2)
If (nRow.HasVersion(DataRowVersion.Proposed) = True) Then
Me.DsGroup_News1.Tables("News").Rows(nRecord)("Vie wed") +=
1

Me.DsGroup_News1.Tables("News").Rows(nRecord)("Dat e_Modify") = Now()
Me.DsGroup_News1.Tables("News").Rows(nRecord)("Ver sion") =
Microsoft.VisualBasic.Right(StatusBarPanel_Version .Text, 8)
If lDelete = True Then

Me.DsGroup_News1.Tables("News").Rows(nRecord)("Dat e_Delete") = Now()
End If
On Sun, 5 Sep 2004 16:16:28 -0500, "VJ" <vi********@yahoo.com> wrote:
I think Martin is looking for something like RowIndex the hexadecimal valuethat is available in Oracle. Are you trying to delete duplicate rows createdby mistake? what are you trying do ? If you are trying to delete dup rows ihave queries that can do that.. let me know .... but if you are looking touse in program I am not aware of it...

VJ

"Martin Heuckeroth" <ni**@nospam.invalid> wrote in message
news:ot********************************@4ax.com.. .


Hi

Any idea on how to get a row number from the original table? We do a
query and get a result. The row number from the result is different
from the rownumber of the table the result originated from. I need the
record number from the original tabel. How do you get THAT number?

Please help,

Regards, Martin

Nov 21 '05 #10

Ok a lot of the previous we found out for ourselves already. Thx for
the input!

Is there any brilliant way to do a search in VB.NET on a table. Any
code? Apparently we are running around in a circle and need to break
out :D

TIA, Martin

On Mon, 6 Sep 2004 22:25:00 +1200, "Richard Myers"
<ri*********************@basd.co.nz> wrote:
O.k what you've posted here is a bunch of dataset related code.

I dont really see what this code has to do with your DBMS explaination. If
the data in this dataset is filled from a table then why not put a Primary
key (MessageId) on the table to use when referring back to the DBMS source
table if thats what your trying to do.

It's would also be a good idea to check out the With keyword, it would help
clean your code up quite a lot and is more performant in places like this.

hth
Richard


"Martin Heuckeroth" <ni**@nospam.invalid> wrote in message
news:pn********************************@4ax.com.. .
We are looking for a way to determine the rownumber of the record in
the original database. Records are renumbered in the relation and we
want to edit/modify the original record in the original table.
Therefore we think we need the recordnumber of the original record in
the original table.

Here some code we brew... We need for nRecord in the 2nd line the
rownumber of the original table where nRecord NOW returns the
recordnumber of the relation.

Function SaveItem()
Dim nRecord As Integer = Me.BindingContext(DsGroup_News1,
"NewsGroup.NewsGroupNews").Position
Console.WriteLine(nRecord)
Dim nRow As DataRow = DsGroup_News1.News.Rows(nRecord)
Dim lDelete As Boolean =
DsGroup_News1.Tables("News").Rows(nRecord)("Record _Delete")
StatusBarSync(2)
If (nRow.HasVersion(DataRowVersion.Proposed) = True) Then
Me.DsGroup_News1.Tables("News").Rows(nRecord)("Vie wed") +=
1

Me.DsGroup_News1.Tables("News").Rows(nRecord)("Dat e_Modify") = Now()
Me.DsGroup_News1.Tables("News").Rows(nRecord)("Ver sion") =
Microsoft.VisualBasic.Right(StatusBarPanel_Version .Text, 8)
If lDelete = True Then

Me.DsGroup_News1.Tables("News").Rows(nRecord)("Dat e_Delete") = Now()
End If
On Sun, 5 Sep 2004 16:16:28 -0500, "VJ" <vi********@yahoo.com> wrote:
>I think Martin is looking for something like RowIndex the hexadecimalvalue >that is available in Oracle. Are you trying to delete duplicate rowscreated >by mistake? what are you trying do ? If you are trying to delete dup rowsi >have queries that can do that.. let me know .... but if you are lookingto >use in program I am not aware of it...
>
>VJ
>
>"Martin Heuckeroth" <ni**@nospam.invalid> wrote in message
>news:ot********************************@4ax.com.. .
>>
>>
>> Hi
>>
>> Any idea on how to get a row number from the original table? We do a
>> query and get a result. The row number from the result is different
>> from the rownumber of the table the result originated from. I need the
>> record number from the original tabel. How do you get THAT number?
>>
>> Please help,
>>
>> Regards, Martin
>


Nov 21 '05 #11

Hi Doug,

The original message was lost in the thread! We are building in VB.NET
on a database in SQL server 2000 and we did find out we cant rely on a
record number but were convinced it would be possible to get them
working reliable. Our bad and all we needed was some armtwisting by
you guys :D
On Mon, 6 Sep 2004 08:38:04 +1000, "Doug Bell" <dug@bigpond> wrote:
Martin,
You haven't said what sort of DB you are connecting to but in any case one
of the rules of relational databases is that rows are un-ordered.
Your table should have a primary key and you could sort by it. You can't
rely on a record number.

Doug

"Martin Heuckeroth" <ni**@nospam.invalid> wrote in message
news:ot********************************@4ax.com.. .


Hi

Any idea on how to get a row number from the original table? We do a
query and get a result. The row number from the result is different
from the rownumber of the table the result originated from. I need the
record number from the original tabel. How do you get THAT number?

Please help,

Regards, Martin


Nov 21 '05 #12
Martin,

To get answers I would never add new questions to old ones, however assuming
you are talking about datatables than there are 3 all different methods. But
really all very powerfull.

The datatable.select (a static select)
http://msdn.microsoft.com/library/de...electtopic.asp

The dataview.rowfilter (a dynamic select)
http://msdn.microsoft.com/library/de...iltertopic.asp

The datarowcollection.find (a static find)
http://msdn.microsoft.com/library/de...sFindTopic.asp

In most cases the dataview.rowfilter is the best (it is faster than a
datatable.select)

I hope this helps?

Cor
Nov 21 '05 #13

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

Similar topics

7
by: Warren Wright | last post by:
Hello, We maintain a 175 million record database table for our customer. This is an extract of some data collected for them by a third party vendor, who sends us regular updates to that data...
4
by: Skully Matjas | last post by:
I am using the following code (created by the wizard) to allow to bring my form to a particular entery. But when I edit the entery (ex: put new information into a blank cell), it puts that record...
5
by: Ilan Sebba | last post by:
When it comes to adding records in related tables, Access is really smart. But when I try to do the same using ADO, I am really stupid. Say I have two parent tables (eg Course, Student) and one...
2
by: windandwaves | last post by:
Hi Guys I have a dilemma: I want to add a record to a table with the following situation: - table has an ID field that is an autonumber - I want to set the ID number to a specific number...
19
by: davidgordon | last post by:
Hi, I need some pointers/help on how to do the following if it possible: In my access db, I have the following: Tables: Products, Sub-Assembly, Product-Pack Table, Products
20
by: Bryan | last post by:
hello all... im trying to add a record to an sql db on ms sql server 2000, using vb.net. seems to be working.. except for one thing, one of the columns in the database is a bit datatype, and...
27
by: Kim Webb | last post by:
I have a field on a form for project number. I basically want it to be the next available number (ie 06010 then 06011 etc). In the form I create a text box and under control source I put: =!=...
5
by: littlevikinggirl | last post by:
Hi, I posted a badly worded question last week so got no replies and am still struggling to figure out the problem myself. I have a table containing two fields, Location and Serial Number. I...
25
by: tekctrl | last post by:
Anyone: I have a simple MSAccess DB which was created from an old ASCII flatfile. It works fine except for something that just started happening. I'll enter info in a record, save the record,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.