6 replies
by glen_mcleod
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
by symesd
by symesd
by wjlarue
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.
by symesd
by symesd
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending