Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add table to Unit-Not Form 1

Status
Not open for further replies.

ThunderForest

IS-IT--Management
Mar 3, 2003
189
US
Using WaveLink Studio
Delphi 4.0
Compiling using DCC32.Exe

I'm trying to add an 'existing' table dynamically to a unit with no form, open it, and list data from it on the barcode scanner menu. I am able to compile the unit, but the program will not load using the WaveLink virtual client (indicative of a crash). If I leave out the code below, the menu program will run. The following code is in Main() in a case statement:

cGun01 is declared as ttable....

ttable.create(cGun01);
cGun01.databaseName := 'c:\...etc...\';
cGun01.tableName := 'cogun01.db';
cGun01.TableType := ttDefault;
cGun01.active := True;

Am I missing anything?

Getting answers before I'm asked
is why I go to Tek-Tips.
 
why not use a datamodule?

--------------------------------------
What You See Is What You Get
 
I'd say the crash is because you haven't declared you're ttable correctly. The parameter in the Create constructor is for the newly created object's owner, not for the object instance itself.

Change

TTable.Create(cGun01);

to

cGun01 := TTable.Create(nil);
 
cGun01 := TTable.Create(nil); worked. Thanks. The TTable creation occurs before a while loop (the menu), and it's definitely getting created now. One of the menu selections (case statements) is simply:

coGun01.active := True;

and now the program crashes when I make this selection. Looks like a fairly reasonable statement. I have the table located in the same location as the program, thinking it was an XP permission issue. The databaseName is correct, which is a path.

Getting answers before I'm asked
is why I go to Tek-Tips.
 
What is the exact error that you get when you try to open the table?

-Dell
 
The only way you can run this program is via an RF hand-held scanner terminal, or the WaveLink virtual client (the latter is more convenient to use for scanner menu development). It essentially emulates a hand-held scanner screen on a PC so you don't have to go out to the warehouse to test your program. Our scanners are DOS based. If there is an error in the application, the connection simply terminates and, unfortunately, you see no error.

I'm having little success in finding sample Delphi code that shows traditional Delphi components in such a menu program. All I've seen is code from their type library. Can anyone point me in the right direction? WaveLink has little to offer, and doesn't pop up on Borland.

Getting answers before I'm asked
is why I go to Tek-Tips.
 
Apologies for the whining here. Looks like the WaveLink client is like TelNet, ie, doesn't recognize network drives. Although the table was local, the Pdoxusrs.Net for the BDE wasn't. Changing it to C:\ allowed the table open. Now it crashes on the next line:

pszTemp := floatToStr(cGun01.fieldByName('ITEM_NO').asFloat);

As I created the table object, do I need to create the fields as objects, even though the table already exists?

At this one line of code per day rate, I should finish this project in about 20 years.

Getting answers before I'm asked
is why I go to Tek-Tips.
 
Using the "AsXXX" property of a field, you actually don't have to do the data conversion. However, you may want to check if the field exists. You could do something like this:
Code:
if cGun01.FindField('ITEM_NO') <> NULL then
  pszTemp := cGun01.fieldByName('ITEM_NO').AsString;

-Dell
 
You are the Delphi hero. I did have to add '.asString' in the findField statement. In any event, I was able to display the field contents on the scanner menu. Looks like I've whittled down that 20 years to yesterday. Thank you very much.

Getting answers before I'm asked
is why I go to Tek-Tips.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top