473,624 Members | 2,469 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Filling in Data Table Using Loop: Check to see if Data Changes

28 New Member
I'm filling in a Report with SQL data using VB code. I'm using LOOP and MoveNext. Before using MoveNext, I would like to be able to check whether the new data is equal to the previous data that was added. I'm not sure if MovePrevious is the best way to accomplish this. Here's an example of my code:

With rs
.MoveFirst
strData = Trim(!data)

Do While Not .EOF

If Not .BOF Then
.MovePrevious
strDataPrev = Trim(!data)
.MoveNext
End If

If (strData <> strDataPrev) Then

'The record is new

End If

.MoveNext
Loop
.Close
End With

Will this work? Or is another method better?
Aug 31 '07 #1
3 2621
Tig201
103 New Member
[quote=nico3334]I'm filling in a Report with SQL data using VB code. I'm using LOOP and MoveNext......Q UOTE]

The first thing I would Note is that you are not setting “strData” After the first Record. Next I would recommend setting “strDataPrev = strData” after you check to see if they are equal as apposed to moving backwards and forwards through the table.
Aug 31 '07 #2
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

Open a New Recordset for the condtion and check with the data.. Why open whole recset and loop thru and do the "Moves"..?

Regards
Veena
Sep 2 '07 #3
nico3334
28 New Member
Hi,

Open a New Recordset for the condtion and check with the data.. Why open whole recset and loop thru and do the "Moves"..?

Regards
Veena
Sorry, I added in some extra code to try to describe my problem better.

I'm retrieving data from a sql table using .movenext and loop. When it is inserting the data, I would like it to check whether the next record it will be adding is equal to the last record it added. If it not is equal, I want to add an occurence to an array. Does this code look ok? Thanks.
''''''''''''''' '''''''
Dim arrData() As String
ReDim arrData(Col, 0)

With rs
.MoveFirst
strData = Trim(!Data)

Do While Not .EOF

If Not .BOF Then
.MovePrevious
strDataPrev = Trim(!Data)
.MoveNext
End If

If (strData <> strDataPrev) Then

'Add Occurence to Array
ReDim Preserve arrData(UBound( Col) + 1)

End If

arrData(Col, 0) = strData

.MoveNext
Loop
.Close
End With
Sep 5 '07 #4

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

Similar topics

1
3160
by: Raptor | last post by:
I'm using a single script to generate a table with <input>s in each row. I fill the array with initial values, then write it out to the table and let the user edit the values. Something like: $myarray = $array(1, 2, 3, ... 100); echo 'Enter your changes, then click Submit:'; foreach ($array as $i) echo '<table tags> <input value="'.$i.'" name="index.'$i.'"> <table tags>';
3
11753
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a table in MySQL with the path & filename to the image. I have successfully uploaded and performed an update query on the database, but the problem I have is I cannot retain the primary key field in a variable which is then used in a SQL update...
3
1997
by: crjunk | last post by:
I have a 3 table in my DataSet that I'm filling with data. After I've filled these 3 tables, I'm then trying to run a query that will fill a 4th table in the DataSet with data from the three tables that are already pouplated. When my code tries to fill the 4th table, ReportData, I receive the following error message: Invalid object name 'tmpPROJECTINFO'. Invalid object name 'tmpContacts'. Invalid object name 'tmpRECEIVEREC'. Can...
11
2154
by: Brian Henry | last post by:
Well here is the problem, I have a data set with about 9,000 to 20,000 people in it in the data table "people"... I am then reading it into a list view one at a time row by row... adding each person to the list view, well this works fine up to about 1,000 people then it start's to get really show putting the people in (a lot of process time used up)... does anyone know of any optimizations i could do to make this processess work a lot...
30
3381
by: Charles Law | last post by:
Here's one that should probably have the sub-heading "I'm sure I asked this once before, but ...". Two users are both looking at the same data, from a database. One user changes the data and commits it. How does the other user get the updated view without polling for changes? Is there some sort of callback mechanism that can be set up on the dataset or connection? TIA
3
5405
by: Martin Panggabean | last post by:
Hello All, I've kind a logic problem ... I want to fill the listView control in VB.NET with data in my mySql table using Datareader object component. But It seems that the way of how listView being used is quite different from usual column-row component like Grid component. If you kind a familiar using listView, u must have known what i'm talking about. Here is some example i took from MSDN :...
9
4012
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New DataTable("SliceInfo") Dim tblSliceRatings As New DataTable("SliceRatings") '.... All the adding datacolumns, datarows, etc. goes here.. DatasetInit.Tables.Add(tblSliceInfo)
4
1694
by: sklett | last post by:
(I posted this in a databinding NG, but it's a VERY low traffic NG so I thought I would post here as well. I hope no one minds too much, if you do I'm sorry) I have a DGV that is bound to a DataTable that is loaded during application startup. I can sort with all the columns and everything works fine. I have a method that can be invoked from a context menu that will loop through the rows of the bound table and modify a specific cell in...
6
2225
by: lukasso | last post by:
Hi, this is my code that should produce something like a timetable for a few days with each day divided into 30 minute pieces. It makes query from MySQL and then creates a 2d $array which then is to be echoed like a table into html. Almost everything goes well except for one entry going for an hour longer and one disappearing if shorter than 1hour (e.g. 30mins) <?php for($i=0; $i<$numRows; $i++) { $result =...
0
8240
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8680
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8625
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8336
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8482
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4082
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2610
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1487
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.