473,748 Members | 2,231 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help Creating Small Table In Memory

Hi Gang

I have a large VB program that at one point does a lookup to a small
table (26 rows by 3 columns). With this table I have to do some
counting and retrieval of data. I'm finding that this slows the
program right down.

Is there any way I can take a copy of the table in memory and access it
there. Perhaps a cursor or something? Can someone help with a code
sample. Here's my code to do the lookup.

'-------------------------------------------------------------------------------------
lcFoundCADIMUOM = "False"
lcPrintUOMNotFo und = ""

Set rsUOMCheck = db.OpenRecordse t("SELECT cadimuom FROM CADIM_UOM WHERE
cadimuom = '" & lcUOM & "'")
If rsUOMCheck.Reco rdCount <> 0 Then
lcFoundCADIMUOM = "True"
End If

If lcFoundCADIMUOM = "False" Then
Set rsUOMCheck = db.OpenRecordse t("SELECT cadimuom FROM CADIM_UOM
WHERE cadimuomconvert = '" & lcUOM & "'")
If rsUOMCheck.Reco rdCount <> 0 Then
lcFoundCADIMUOM = "True"
lcUOM = rsUOMCheck("cad imuom")
End If
End If

If lcFoundCADIMUOM = "False" Then
lcPrintUOMNotFo und = lcPrintUOMNotFo und & lcUOM & Chr(10)
End If
'-------------------------------------------------------------------------------------
Thanks
Andy

Jan 10 '06 #1
4 5492
Per an***********@s iemens.com:
Perhaps a cursor or something? Can someone help with a code
sample. Here's my code to do the lookup.


Just in plain English, what are you trying to do?
--
PeteCresswell
Jan 10 '06 #2
Andy, to create a "table" in memory, of sorts, you can use
multi-dimensional arrays (or arrays of arrays, as someone pointed out
in a recent thread). Then you would read the table into your array and
access the information stored in memory. I would think that a Recordset
does basically the same thing, but I don't know - that's something the
smarter, more experienced folks on here could probably answer. However,
if the Recordset is reading data from the drive continually, it would
be much faster to use a copy in memory. I notice, though, that under
some circumstances you reopen the recordset to get a different
field...could you just get both fields in the original recordset?

Multidimensiona l arrays work like this:
Dim arrRay As String(26, 3)

arrRay(0,1)="Va lue of Row0, Col1"
arrRay(0,2)="Va lue of Row0, Col2"
arrRay(0,3)="Va lue of Row0, Col3"

arrRay(1,1)="Va lue of Row1, Col1"

Making sense?

There's even a Recordset method that turns the Recordset into a
multidimensiona l array for you. You can then use loops to iterate
through the array, like you would a table, and do your calculations.

Jan 10 '06 #3
Andy, ADO does disconnected recordsets: you can load the
recordset into memory, and use Find on it. If you want
to use ADO, perhaps you could repost with something
like "How to do ADO disconnected recordset?"

It's not clear from your code: do you call this function
repeatedly? If it is only called once, there is not
much you can do to make it faster. You still have to
load the data from disk into memory.

You might find that your code runs faster if you
only load the recordset once. For example if
CADIM_UOM is a table in db, you could open it as
a table object, and use SEEK

(air code)

Set rs = db.OpenRecordse t("CADIM_UOM" )
rs.index = "cadimuom"
rs.seek lcUOM

(david)

<an***********@ siemens.com> wrote in message
news:11******** *************@o 13g2000cwo.goog legroups.com...
Hi Gang

I have a large VB program that at one point does a lookup to a small
table (26 rows by 3 columns). With this table I have to do some
counting and retrieval of data. I'm finding that this slows the
program right down.

Is there any way I can take a copy of the table in memory and access it
there. Perhaps a cursor or something? Can someone help with a code
sample. Here's my code to do the lookup.

'-------------------------------------------------------------------------------------
lcFoundCADIMUOM = "False"
lcPrintUOMNotFo und = ""

Set rsUOMCheck = db.OpenRecordse t("SELECT cadimuom FROM CADIM_UOM WHERE
cadimuom = '" & lcUOM & "'")
If rsUOMCheck.Reco rdCount <> 0 Then
lcFoundCADIMUOM = "True"
End If

If lcFoundCADIMUOM = "False" Then
Set rsUOMCheck = db.OpenRecordse t("SELECT cadimuom FROM CADIM_UOM
WHERE cadimuomconvert = '" & lcUOM & "'")
If rsUOMCheck.Reco rdCount <> 0 Then
lcFoundCADIMUOM = "True"
lcUOM = rsUOMCheck("cad imuom")
End If
End If

If lcFoundCADIMUOM = "False" Then
lcPrintUOMNotFo und = lcPrintUOMNotFo und & lcUOM & Chr(10)
End If
'-------------------------------------------------------------------------------------
Thanks
Andy

Jan 11 '06 #4
rkc
an***********@s iemens.com wrote:
Hi Gang

I have a large VB program that at one point does a lookup to a small
table (26 rows by 3 columns). With this table I have to do some
counting and retrieval of data. I'm finding that this slows the
program right down.

Is there any way I can take a copy of the table in memory and access it
there. Perhaps a cursor or something? Can someone help with a code
sample. Here's my code to do the lookup.

'-------------------------------------------------------------------------------------
lcFoundCADIMUOM = "False"
lcPrintUOMNotFo und = ""

Set rsUOMCheck = db.OpenRecordse t("SELECT cadimuom FROM CADIM_UOM WHERE
cadimuom = '" & lcUOM & "'")
If rsUOMCheck.Reco rdCount <> 0 Then
lcFoundCADIMUOM = "True"
End If

If lcFoundCADIMUOM = "False" Then
Set rsUOMCheck = db.OpenRecordse t("SELECT cadimuom FROM CADIM_UOM
WHERE cadimuomconvert = '" & lcUOM & "'")
If rsUOMCheck.Reco rdCount <> 0 Then
lcFoundCADIMUOM = "True"
lcUOM = rsUOMCheck("cad imuom")
End If
End If

If lcFoundCADIMUOM = "False" Then
lcPrintUOMNotFo und = lcPrintUOMNotFo und & lcUOM & Chr(10)
End If
'-------------------------------------------------------------------------------------

For raw speed my money is on:
Loading each individual set of fields into a delimited string and using
the instr() function to search for your target values.


Jan 11 '06 #5

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

Similar topics

6
1761
by: Graham Pengelly | last post by:
Hi I'll try to spell out my problem as succinctly as possible... My database has a User table, an Organisation table, a Department table and a JobType table (amongst others) The Organisation table has a one to many relationship with the other three. The User table contains foreign keys to the Department and JobType tables (and the Organisation table).
5
2317
by: SStory | last post by:
Hi all, I really needed to get the icons associated with each file that I want to show in a listview. I used the follow modified code sniplets found on the internet. I have left in commented code for anyone else who may be looking to do the same.
6
2254
by: Pablo | last post by:
Hello, I am writing a windows application using C++ and BorlandBuilder 6 compiler. It is an event driven program and I need to create objects of some classes written by me. One of the classes contains a pointer to int values as a filed. In the definition (implementation) of constructor I use this pointer to create table of int values with the new operator. The number of elements of the table is provided by the user during execution of the...
16
2814
by: Rex | last post by:
Hi All - I have a question that I think MIGHT be of interest to a number of us developers. I am somewhat new to VIsual Studio 2005 but not new to VB. I am looking for ideas about quick and efficient navigating within Visual Studio 2005. Let's say your project (or solution) has dozens of forms and hundreds or even thousands of routines. Two Questions: 1) BUILT-IN to Visual Studio 2005. What ideas do you have to quickly
15
2579
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to determine who needs to receive the text message then send the message to the address. Only problem is, the employee may receive up to 4 of the same messages because each thread gets the recors then sends the message. I need somehow to prevent...
0
5573
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
3
3016
by: cuties | last post by:
Hi all.... i'm very new to this programming language. i'm required to fulfill this task in the company i'm doing my practical. i hope i can get guide for my problem... Here is the script i already wrote but i'm having problem to move forward. my problem is : 1. how do i assign each checkbox to have equal value with the value of the d_id?
2
2005
by: Dr Dav | last post by:
Hello all, I'm a physicist whose rewriting a numerical simulation, previously written in IDL, in C with the goal reducing runtime. As you may imagine, my C programming skills are quite poor but I am learning. My problem is this. I had sucessfully written a C code that worked ( with considerable speedup over the IDL version ) using an array size of 100x100. However, I am working towards making the array size closer to 300x300. Since I had...
32
2566
by: Joe | last post by:
I am just starting to use Object Oriented PHP coding, and I am seeing quite often the following (this example taken from a wiki): $wakka =& new Wakka($wakkaConfig); What exactly is the =&, and why is it different from = ?
0
8979
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
8818
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9522
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
9355
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
9307
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
9225
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
6069
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
4589
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...
2
2773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.