F
fniles
I am using VB.NET 2005 and Access.
In my Access database I have a table called Test with 3 columns (id, col1
and col2).
I have a query called "qtest" as "SELECT test.id, test.col1, test.col2,
col1-col2 AS x FROM test"
In VB.NET I run the query as "select * from qtest order by x desc"
The result of query qtest look like the following:
ID col1 col2 x
a 100 0 100
b 30 0 30
c 25 0 25
Then, I select a record where x > 0 like so:
m_rowSelect = m_ds.Tables(0).Select("x > 0")
What it returns is the following record:
ID col1 col2 x
c 25 0 25
instead of the following record:
ID col1 col2 x
a 100 0 100
Since my query is sorted by "x desc", why the row select does not return ID
a, instead it returns ID c ?
It looks like the rowselect look for the record closest to x > 0, instead of
the 1st record it finds that meet x > 0.
Thank you.
Dim m_rowSelect As DataRow()
Private m_cmd As OleDb.OleDbCommand
Dim m_ds As DataSet
Private m_da As OleDb.OleDbDataAdapter
m_cmd = New OleDb.OleDbCommand
With m_cmd
.Connection = adoConOLE
.CommandText = "select * from qtest order by x desc"
End With
m_da = New OleDb.OleDbDataAdapter
m_ds = New DataSet
m_da.SelectCommand = m_cmd
m_da.Fill(m_ds)
m_rowSelect = m_ds.Tables(0).Select("x > 0")
qrem = m_rowSelect(0).Item("x") -> returns 25
refid = m_rowSelect(0).Item("id") -> returns c
Thank you
In my Access database I have a table called Test with 3 columns (id, col1
and col2).
I have a query called "qtest" as "SELECT test.id, test.col1, test.col2,
col1-col2 AS x FROM test"
In VB.NET I run the query as "select * from qtest order by x desc"
The result of query qtest look like the following:
ID col1 col2 x
a 100 0 100
b 30 0 30
c 25 0 25
Then, I select a record where x > 0 like so:
m_rowSelect = m_ds.Tables(0).Select("x > 0")
What it returns is the following record:
ID col1 col2 x
c 25 0 25
instead of the following record:
ID col1 col2 x
a 100 0 100
Since my query is sorted by "x desc", why the row select does not return ID
a, instead it returns ID c ?
It looks like the rowselect look for the record closest to x > 0, instead of
the 1st record it finds that meet x > 0.
Thank you.
Dim m_rowSelect As DataRow()
Private m_cmd As OleDb.OleDbCommand
Dim m_ds As DataSet
Private m_da As OleDb.OleDbDataAdapter
m_cmd = New OleDb.OleDbCommand
With m_cmd
.Connection = adoConOLE
.CommandText = "select * from qtest order by x desc"
End With
m_da = New OleDb.OleDbDataAdapter
m_ds = New DataSet
m_da.SelectCommand = m_cmd
m_da.Fill(m_ds)
m_rowSelect = m_ds.Tables(0).Select("x > 0")
qrem = m_rowSelect(0).Item("x") -> returns 25
refid = m_rowSelect(0).Item("id") -> returns c
Thank you