473,471 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
Create 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"
lcPrintUOMNotFound = ""

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

If lcFoundCADIMUOM = "False" Then
Set rsUOMCheck = db.OpenRecordset("SELECT cadimuom FROM CADIM_UOM
WHERE cadimuomconvert = '" & lcUOM & "'")
If rsUOMCheck.RecordCount <> 0 Then
lcFoundCADIMUOM = "True"
lcUOM = rsUOMCheck("cadimuom")
End If
End If

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

Jan 10 '06 #1
4 5470
Per an***********@siemens.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?

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

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

arrRay(1,1)="Value of Row1, Col1"

Making sense?

There's even a Recordset method that turns the Recordset into a
multidimensional 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.OpenRecordset("CADIM_UOM")
rs.index = "cadimuom"
rs.seek lcUOM

(david)

<an***********@siemens.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.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"
lcPrintUOMNotFound = ""

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

If lcFoundCADIMUOM = "False" Then
Set rsUOMCheck = db.OpenRecordset("SELECT cadimuom FROM CADIM_UOM
WHERE cadimuomconvert = '" & lcUOM & "'")
If rsUOMCheck.RecordCount <> 0 Then
lcFoundCADIMUOM = "True"
lcUOM = rsUOMCheck("cadimuom")
End If
End If

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

Jan 11 '06 #4
rkc
an***********@siemens.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"
lcPrintUOMNotFound = ""

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

If lcFoundCADIMUOM = "False" Then
Set rsUOMCheck = db.OpenRecordset("SELECT cadimuom FROM CADIM_UOM
WHERE cadimuomconvert = '" & lcUOM & "'")
If rsUOMCheck.RecordCount <> 0 Then
lcFoundCADIMUOM = "True"
lcUOM = rsUOMCheck("cadimuom")
End If
End If

If lcFoundCADIMUOM = "False" Then
lcPrintUOMNotFound = lcPrintUOMNotFound & 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
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...
5
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...
6
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...
16
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...
15
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...
0
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...
3
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...
2
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...
32
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...
0
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,...
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...
1
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...
0
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.