For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic Syntax > February 2005 > Using ADODB









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Using ADODB
Khai

2005-02-04, 4:01 pm

Hi -

I have one program that creates a Visual FoxPro Database file, that is a
single record with a table in it. Then, my Word uses it as a merge source.

The only thing is - the guy who programmed the Foxpro part is a real jerk
and left in an storm. So, guess who got stuck with it all? :D

Now, I don't want to completely get rid of his program because it works
pretty dang well, but - I need to tap into that dbf file when the merge
occours.

I've used the DataSource.Items functions, but- that's slow, and I understand
I can connect via ADO to the file, and get info much faster that way.

I'm looking for some help in understanding ADO a bit more thoroughly, more
specifically, how I would build the connection string.

I can use MSQuery to connect to the file, but i can't figure out how exactly
it connects.

Does anyone have any great websites on learning how to use ADO, and if I'm
missing a step, the whole connection string method?

It seems that all the websites I find are more "you already have to know
this stuff before I can explain furthere." But finding "here's where the
whole things starts" is a bit more tricky.

I would be happy to provide a copy of the dbf (<10k) if anyone wants to help
out of the kindness of their heart. ;) Or atleast direct me to a very solid
starting source to learn from.

-Thanks,
DPharr


Jeff Johnson [MVP: VB]

2005-02-04, 4:01 pm


"Khai" <middae*nospam*@*nO_Spam*hotmail.com> wrote in message
news:1tydnVGRfIXXLp7fRVn-3Q@comcast.com...

> I have one program that creates a Visual FoxPro Database file, that is a
> single record with a table in it.


Or a table with a single record in it, perchance?

> I'm looking for some help in understanding ADO a bit more thoroughly, more
> specifically, how I would build the connection string.


Can you tell me what version of FoxPro created the file? It may make a
difference on which provider to use.

Alternatively, you could take a look at www.able-consulting.com/ADO_Conn.htm
and you might be able to figure it out for yourself.


Khai

2005-02-04, 8:59 pm

I guess VFP asks you to log in when you use this program he wrote. There's
a help menu that says

Microsoft Visual FoxPro 6.0 SP3
Version 06.00.8492.00

if I open the wordtbl.dbf from Notepad, it lists the field names up top,
then the data for the only record down below, so Yes, I think you're correct
about One table with One record.

I managed to get a little le-way today! :D I got WordVBA to open it and
send back a RS.Open "Select * from wordtbl", myADO, then msgbox rs.fields(1)
.. I use an ADODB.Connection object from Microsoft ActiveX Data Objects
Library 2.5, and used myADO.Provider= "Foxpro", but, I'd prefer to be able
to connect DSNless with using the Provider value, instead of relying on an
DSN to /always/ be named the same thing, even though the Wordtbl.dbf is
/always/ in the same place.

Plus, it means I'm getting a little closer to truly understanding this stuff
if I do it the hard way. :) I checked out the file that Word creates when
you add a Database to the activedocument. It says "Driver=Microsoft Visual
Fox Pro Driver" in there, and I tried that, but no luck.

This is a lot of work just to get the only record that's re-written for
every merge. Heheh.

Thanks, and I checked out the site. :)

*Comments?*

-DPHarr
"Jeff Johnson [MVP: VB]" <i.get@enough.spam> wrote in message
news:%23G4VbVuCFHA.3132@TK2MSFTNGP09.phx.gbl...
>
> "Khai" <middae*nospam*@*nO_Spam*hotmail.com> wrote in message
> news:1tydnVGRfIXXLp7fRVn-3Q@comcast.com...
>
>
> Or a table with a single record in it, perchance?
>
more[color=darkred]
>
> Can you tell me what version of FoxPro created the file? It may make a
> difference on which provider to use.
>
> Alternatively, you could take a look at

www.able-consulting.com/ADO_Conn.htm
> and you might be able to figure it out for yourself.
>
>



Jeff Johnson [MVP: VB]

2005-02-04, 8:59 pm


"Khai" <middae*nospam*@*nO_Spam*hotmail.com> wrote in message
news:ktadnZXjK-AxTp7fRVn-1A@comcast.com...

> . I use an ADODB.Connection object from Microsoft ActiveX Data Objects
> Library 2.5, and used myADO.Provider= "Foxpro", but, I'd prefer to be able
> to connect DSNless with using the Provider value, instead of relying on an
> DSN to /always/ be named the same thing, even though the Wordtbl.dbf is
> /always/ in the same place.


Provider="Foxpro"? Really? And it worked?

Could you post the actual code. It really sounds like you're there already.
DSNs only exist in ODBC, so if you're using pure ADO (i.e., and OLE DB
provider) then you're already there and just don't know it.


Khai

2005-02-04, 8:59 pm

Private Sub CreateRecords() 'using ADODB 'references Microsoft ActiveX Data
Objects 2.6 Library
Dim MA As myApp 'my own datatype
Dim maxsize%
Dim tstr$, tstr2$
Dim myF As Integer 'myF for File Writing
Dim myADO As ADODB.Connection
Dim rs As ADODB.Recordset

Set myADO = New ADODB.Connection
Set rs = New ADODB.Recordset

myADO.Open "Visual FoxPro Database"
rs.Open "select * from wordtbl", myADO
with rs
MA.twccnum = .fields("twccnum")
Jeff Johnson [MVP: VB]

2005-02-07, 9:04 pm


"Khai" <middae*nospam*@*nO_Spam*hotmail.com> wrote in message
news:evudnd1IFI62aJ7fRVn-pQ@comcast.com...

> myADO.Open "Visual FoxPro Database"


Sorry, but I haven't had a chance to look too deeply into this yet.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com