473,671 Members | 2,155 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 5481
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
1755
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
2312
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
2249
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
2795
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
2569
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
5558
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
3007
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
2001
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
2559
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
8393
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,...
1
8598
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,...
1
6223
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5695
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
4224
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...
0
4406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2810
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
2051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1809
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.