General discussion

Locked

creating VisualFoxPro record from VB

By symesd ·
Is there a way in Visual Basic to create a visual FoxPro table? We have an extremely large text file to import into VFP and need to just create and store the records in the VFP tables as we parse the text (i/p) file.

This conversation is currently closed to new comments.

6 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

creating VisualFoxPro record from VB

by Glen_McLeod In reply to creating VisualFoxPro rec ...

I've never tried it with VFP, but by combining the right ADO provider with ADOX, you should be able to accomplish what you're trying to do here. I've done it with SQL Server, Oracle and Access.

ADOX will let you manipulate the actual objects in your data source (tables, fields, queries, relationships) like you could in DAO with tabledef objects and the like. It's just that ADO has them in separate components where DAO had them all together.

Just think of ADODB as DML (Data Manipulation Language: Select, Update, ...), and ADOX as DDL (Data Definition Language: Create Table, ...).

Glen

Collapse -

creating VisualFoxPro record from VB

by symesd In reply to creating VisualFoxPro rec ...

Poster rated this answer

Collapse -

creating VisualFoxPro record from VB

by symesd In reply to creating VisualFoxPro rec ...

Point value changed by question poster.

Collapse -

creating VisualFoxPro record from VB

by wjlarue In reply to creating VisualFoxPro rec ...

I have found through experience that using Visual FoxPro as a data source in Visual Basic can be flaky at times. Take the code example I am about to offer. It worked at one time on my machine but then I started to get a SQLSetConnectAttr error when trying to establish a connection. The "CREATE TABLE" statement is the main focus anyway.

'Start of code
Dim strConnection As String
Dim strCreate As String
Dim cnnMyConnect As ADODB.Connection
Dim cmdMyCommand_Create As ADODB.Command

strCreate = "CREATE TABLE MyTable (CharField C(10) NULL, DateField D NOT NULL, NumField N(10,2) NOT NULL)"

strConnection = "DRIVER=Microsoft Visual FoxPro Driver;UID=;Deleted=Yes;Null=Yes;Collate=Machine;" & _
"BackgroundFetch=Yes;Exclusive=No;SourceType=DBF;SourceDB=c:\temp"

'create and open active connection
Set cnnMyConnect = New ADODB.Connection
cnnMyConnect.Open strConnection

'set and execute command
Set cmdMyCommand_Create = New ADODB.Command
Set cmdMyCommand_Create.ActiveConnection = cnnMyConnect
cmdMyCommand_Create.CommandText = strCreate
cmdMyCommand_Create.Execute

'Clean up
Set cmdMyCommand_Create = Nothing

cnnMyConnect.Close
Set cnnMyConnect = Nothing
'End of code

Here is a full list of FoxPro field types:

FieldType nFieldWidth nPrecision Description
C n ? Character field of width n
D ? ? Date
T ? ? DateTime
N n d Numeric width n with d decimal places
F n d Float width n with d decimal places
I ? ? Integer
B ? d Double
Y ? ? Currency
L ? ? Logical
M ? ? Memo
G ? ? General

I have created some very successful application using VFP as the data source in a VB/ADO environment but it?s never been my first choice. Good luckin your endeavors and I hope this helps you.

Collapse -

creating VisualFoxPro record from VB

by symesd In reply to creating VisualFoxPro rec ...

thanks - will try

Collapse -

creating VisualFoxPro record from VB

by symesd In reply to creating VisualFoxPro rec ...

This question was closed by the author

Back to Web Development Forum
6 total posts (Page 1 of 1)  

Related Discussions

Related Forums