BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

table fields

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Desktop)
View previous topic :: View next topic  
Author Message
Edmund
Guest





PostPosted: Wed Jan 17, 2007 9:11 am    Post subject: table fields Reply with quote



Dear All,

I'm trying to access FoxPro tables via BDE+ODBC and so
far, I can see the tables when I link up a dbgrid
component on a form. I'm using Delphi 7, btw.

However, I'm also trying to do a console app, so
there are no visual clues as to whether the linkage
is 'ok'.

So far, I believe I have it running up to a certain
point, but I've come across a strange issue.

Here's the code:

dbx := TDatabase.Create(nil);
tb := TTable.Create(nil);

dbx.DatabaseName := 'tdata2';
dbx.LoginPrompt := false;
dbx.params.Add('USER NAME=myUser');
dbx.params.add('PASSWORD=myPass');
dbx.Connected := true;

tb.Databasename := 'tdata2';
tb.TableName := 'fignfo';
tb.Open;
tb.First;

writeln(tb.fieldcount);
writeln(tb.FieldDefs.Items[0].Name);
writeln(tb.Fields.Count);
mx := tb.RecordCount;
writeln(mx);


When I run the above, I get:

0
matnfo
0
-25917

I am so confused here I don't know where to start. If
I can display the FieldDefs.item[0].name, then that
means the table is connected to the Foxpro table.
I know for a fact (via the Form application table)
that there exists values in that table.

Yet, I'm seeing a zero field count? I don't understand.
It just makes zero sense.

Can someone shed some light as to what I'm missing?

Any help really appreciated. Thanks.

Edmund
Back to top
Rick Carter
Guest





PostPosted: Thu Jan 18, 2007 12:52 am    Post subject: Re: table fields Reply with quote



Quote:
I'm trying to access FoxPro tables via BDE+ODBC and so
far, I can see the tables when I link up a dbgrid
component on a form. I'm using Delphi 7, btw.

I think you would probably do better to switch to ADO for access to your
FoxPro tables. Or, you could use Advantage Database Server -- the local
server is free.

The BDE hasn't been updated for years, and is mainly still there just to
support local Paradox and dBASE tables. There are known problems using
the BDE to directly access FoxPro tables, and apparently with the BDE and
your ODBC driver things aren't going well either.

Rick Carter
carterrk (AT) despammed (DOT) com
Chair, Delphi/Paradox SIG, Cincinnati PC Users Group

--- posted by geoForum on http://delphi.newswhat.com
Back to top
Edmund
Guest





PostPosted: Thu Jan 18, 2007 6:27 am    Post subject: Re: table fields Reply with quote



Didn't you write?:
Quote:
I'm trying to access FoxPro tables via BDE+ODBC and so
far, I can see the tables when I link up a dbgrid
component on a form. I'm using Delphi 7, btw.

I think you would probably do better to switch to ADO for access to your
FoxPro tables. Or, you could use Advantage Database Server -- the local
server is free.

Well, Advantage Database Server (or at least, ANY database server other
than Foxpro tables) would be a bonus for me, but since I'm trying
to access data from work that's being used by a 3rd party program,
there's little I can do.

As for ADO access, I'll check it out. Thanks for the info.
Accessing Foxpro data via BDE works only 60% of the time.
The other 40% or so throws 'not enough memory' errors. :I


Quote:

The BDE hasn't been updated for years, and is mainly still there just to
support local Paradox and dBASE tables. There are known problems using
the BDE to directly access FoxPro tables, and apparently with the BDE and
your ODBC driver things aren't going well either.

Well, I certainly hope there'll be some concrete replacement for
BDE, or is ADO it? (Mind you, I haven't checked out ADO yet
so I could be pleasantly surprised.)

Edmund
Back to top
Bill Todd
Guest





PostPosted: Thu Jan 18, 2007 6:31 am    Post subject: Re: table fields Reply with quote

Edmund wrote:

Quote:
Well, I certainly hope there'll be some concrete replacement for
BDE, or is ADO it?

It depends on what database you are trying to access. For Paradox
tables the BDE is the only game in town since the BDE is the Paradox
DBMS. For other desktop databases ADO is the best choice since you
should be able to find an ODBC or OLE DB driver for the database. For
SQL database servers the CodeGear replacement is dbExpress. You can
also use ADO or you can use proprietary components for those databases
that provide them.

--
Bill Todd (TeamB)
Back to top
Edmund
Guest





PostPosted: Thu Jan 18, 2007 7:38 am    Post subject: Re: table fields Reply with quote

Quote:

It depends on what database you are trying to access. For Paradox
tables the BDE is the only game in town since the BDE is the Paradox

Well, I'm just trying to access Foxpro tables. Nothing fancy.

I'm trying to use the ADO set of components, but it seems a little
daunting. While I do have a small program done, it unfortunately
doesn't work due to the 'CoInitialize has not been called' error.
From what I gathered while googling, it has something to do with
Application.Initialize not being executed.

The problem I have with this is this program is supposed to be
a console app and thusly would not require the Application.initialize,
right? Also from the googles, it states that I need to code
the CoInitialize command directly. But from the Delphi 7
help file, I don't see the command CoInitialize anywhere.

Am I mistaken that i can't use ADO with console apps?
(I figured this would be similar to coding a Service
no?)

Any clarifications appreciated.

Edmund
Back to top
Brian Bushay TeamB
Guest





PostPosted: Thu Jan 18, 2007 8:16 am    Post subject: Re: table fields Reply with quote

Quote:
It depends on what database you are trying to access. For Paradox
tables the BDE is the only game in town since the BDE is the Paradox

Well, I'm just trying to access Foxpro tables. Nothing fancy.

I'm trying to use the ADO set of components, but it seems a little
daunting. While I do have a small program done, it unfortunately
doesn't work due to the 'CoInitialize has not been called' error.
From what I gathered while googling, it has something to do with
Application.Initialize not being executed.

The problem I have with this is this program is supposed to be
a console app and thusly would not require the Application.initialize,
right? Also from the googles, it states that I need to code
the CoInitialize command directly. But from the Delphi 7
help file, I don't see the command CoInitialize anywhere.

Am I mistaken that i can't use ADO with console apps?
(I figured this would be similar to coding a Service
no?)

Any clarifications appreciated.

Ado is uses COM so you need coInitialize to initialize COM.
You can use it with a console application
You need the ActiveX unit in your uses

CoInitialize(nil);

Then you need to call
CoUnitialize when your application terminates
--
Brian Bushay (TeamB)
Bbushay (AT) NMPLS (DOT) com
Back to top
Edmund
Guest





PostPosted: Thu Jan 18, 2007 8:25 am    Post subject: Re: table fields Reply with quote

Didn't you write?:
Quote:

Ado is uses COM so you need coInitialize to initialize COM.
You can use it with a console application
You need the ActiveX unit in your uses

CoInitialize(nil);

Then you need to call
CoUnitialize when your application terminates

Hi Brian! It just so happens the googled results came up
with your name 2 out of 2 clicks. Excellent record, I'd
say. :)

So basically I do:

uses
ActiveX; (or whatever it's called, I'll probably find
this out.)

begin
CoInitialize(nil);
...
(more code)
...
CoUnInitialize;

end.

Right?


Very much appreciated for the quick response!

Edmund
Back to top
Rick Carter
Guest





PostPosted: Thu Jan 18, 2007 11:34 pm    Post subject: Re: table fields Reply with quote

Quote:
I think you would probably do better to switch to ADO for access to
your
FoxPro tables. Or, you could use Advantage Database Server -- the
local
server is free.

Well, Advantage Database Server (or at least, ANY database server other
than Foxpro tables) would be a bonus for me, but since I'm trying
to access data from work that's being used by a 3rd party program,
there's little I can do.

ADS works not only with its own proprietary data format, but also will
work with FoxPro tables and indexes. And Clipper tables, too, FWIW.

Rick Carter
carterrk (AT) despammed (DOT) com
Chair, Delphi/Paradox SIG, Cincinnati PC Users Group

--- posted by geoForum on http://delphi.newswhat.com
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Desktop) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.