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

RowSelect

I use Dataset and to select certain records in the Dataset I use the SELECT
method (m_dsSQL.Tables(0).Select("colB 0") ).
I am looping until colB <= 0.
The problem is, after I fill the dataset and do SELECT, if inside the LOOP I
change the value of ColB, it is not being reflected in the Dataset SELECT.
Is there a way in the LOOP to reflect the changes that has been made in colB
?
For ex:

Dim m_daSQL As SqlClient.SqlDataAdapter
Dim m_cmdSQL As SqlClient.SqlCommand
Dim m_dsSQL As DataSet
Dim aRowHistTrades As DataRow()
dim bContinue as boolean
dim sSQL as string

sSQL = "select * from myTable where ColA = 'ABC'"
m_cmdSQL = New SqlClient.SqlCommand
With m_cmdSQL
.Connection = adoCon
.CommandText = sSQL
End With
m_daSQL = New SqlClient.SqlDataAdapter
m_dsSQL = New DataSet
m_daSQL.SelectCommand = m_cmdSQL
m_daSQL.Fill(m_dsSQL)
bContinue = True
'--->Here i want to loop thru myTable until colB is <= 0
Do While bContinue
'--->after the 1st iteration, colB value is changed, but the code below
does not reflect that.
'--->For ex: ColB starts with value = 2.5, after 1st iteration, in the
database colB = 1.5
'--->but the following code does not reflect that, colB stays at 2.5,
thus aRowHistTrades.Length is always 0
aRowHistTrades = m_dsSQL.Tables(0).Select("colB 0")
If aRowHistTrades.Length 0 Then
: --If ColB is still 0 then, do some codes that changes/reduces the
value of ColB
colB = aRowHistTrades(0).Item("colB") '--after 1st iteration,
this value is still the same with before 1st iteration
Else
bContinue = False
End If
Loop

Thank you.
Aug 7 '07 #1
1 1434
fniles,

A dataset is not a recordset. There is not any equality in it. What looks
the most as a recordset is a datatable, with the main difference that a
recordset is always connected to the database and the datatable is (without
additions) forever disconnected.

This means that you fill a datatable, make mutation to it, and then update
it.

For updating you can set the Update, Delete and Insert properties in the
dbcommandmethod that you are using.

For the later you can use as well the dbcommandbuilder.

In your case I would first try this with a sample and the NorthWind sample
database.

Here a sample that is easy to make, don't use it in real life, it will eat
up your process as in fact the recordset can do (the recordset is from the
time that 100 concurrent users was in most cases much).

http://www.vb-tips.com/SQLServerUpdate.aspx

Cor


"fniles" <fn****@pfmail.comschreef in bericht
news:%2***************@TK2MSFTNGP02.phx.gbl...
>I use Dataset and to select certain records in the Dataset I use the SELECT
method (m_dsSQL.Tables(0).Select("colB 0") ).
I am looping until colB <= 0.
The problem is, after I fill the dataset and do SELECT, if inside the LOOP
I change the value of ColB, it is not being reflected in the Dataset
SELECT.
Is there a way in the LOOP to reflect the changes that has been made in
colB ?
For ex:

Dim m_daSQL As SqlClient.SqlDataAdapter
Dim m_cmdSQL As SqlClient.SqlCommand
Dim m_dsSQL As DataSet
Dim aRowHistTrades As DataRow()
dim bContinue as boolean
dim sSQL as string

sSQL = "select * from myTable where ColA = 'ABC'"
m_cmdSQL = New SqlClient.SqlCommand
With m_cmdSQL
.Connection = adoCon
.CommandText = sSQL
End With
m_daSQL = New SqlClient.SqlDataAdapter
m_dsSQL = New DataSet
m_daSQL.SelectCommand = m_cmdSQL
m_daSQL.Fill(m_dsSQL)
bContinue = True
'--->Here i want to loop thru myTable until colB is <= 0
Do While bContinue
'--->after the 1st iteration, colB value is changed, but the code
below does not reflect that.
'--->For ex: ColB starts with value = 2.5, after 1st iteration, in the
database colB = 1.5
'--->but the following code does not reflect that, colB stays at 2.5,
thus aRowHistTrades.Length is always 0
aRowHistTrades = m_dsSQL.Tables(0).Select("colB 0")
If aRowHistTrades.Length 0 Then
: --If ColB is still 0 then, do some codes that changes/reduces the
value of ColB
colB = aRowHistTrades(0).Item("colB") '--after 1st iteration,
this value is still the same with before 1st iteration
Else
bContinue = False
End If
Loop

Thank you.
Aug 8 '07 #2

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

Similar topics

2
by: Red Green | last post by:
In a Delphi datagrid there is a RowSelect property that highlights the currently selected row and does not allow the user to edit individual fields. Is there anything like this in the windows .NET...
3
by: Nilz | last post by:
Hi all, i am using UltraWinGrid in my application and i want to change the Back Color of the Active Cell to transparent. i have defined CellClickAction as RowSelect. So if we click on the cell the...
1
by: Kashif Mehmood | last post by:
Greeting I am using the following code to delete a row from a datagrid ---------------- Private Sub dgClientTypes_DeleteCommand(ByVal source As Object, ByVal e As...
6
by: Bill Nguyen | last post by:
I need to add a checkbox in front of all the rows in a datagrid so that users can select/unselect them. Any help is greatly appreciated! Bill
8
by: ameen.abdullah | last post by:
Hi Guys, I have a checked list box on my form.. the purpose of this checkbox is to indicate that the option is enabled or disabled.. I just want to ask if there is a way to disable these check...
1
by: Eric Effer | last post by:
Hi everyone I am tryin to get the selected index from this gridview while selecting the radiobuttonlist. I dont want to use a button for the row though. Anyone knows how to do this? thnks ...
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: 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
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
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
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,...

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.