Anderson_Enterprises
asked on
ODBC, VB, [Data Control | ADO Data Control] -- I need to connect and release when requested.
My data control hogs up access to the FoxPro database (through ODBC) and prevents my program from Zapping the records.
I am making an ActiveX Calendar Control.
Here is the order of operations
User clicks the Tab in FoxPro.
FoxPro USE EXCLUSIVE's the Calendar table, Clears it. Loads it with real data. Then tells the calendar to REFRESH based on the new data.
Everything works, except i get an error telling me that fox cant use the database exclusive because the control has a finger in it.
How can i (programically) create the connection?
I'm using a Data Control (vb6) and have been told to switch to ADO data control.
I DO NOT WANT TO SET THE CONNECTION THROUGH THE PROPERTY WINDOW BECAUSE I NEED TO START AND STOP IT VIA CODE.
Cheers, It's important : ) So answer quickly
I am making an ActiveX Calendar Control.
Here is the order of operations
User clicks the Tab in FoxPro.
FoxPro USE EXCLUSIVE's the Calendar table, Clears it. Loads it with real data. Then tells the calendar to REFRESH based on the new data.
Everything works, except i get an error telling me that fox cant use the database exclusive because the control has a finger in it.
How can i (programically) create the connection?
I'm using a Data Control (vb6) and have been told to switch to ADO data control.
I DO NOT WANT TO SET THE CONNECTION THROUGH THE PROPERTY WINDOW BECAUSE I NEED TO START AND STOP IT VIA CODE.
Cheers, It's important : ) So answer quickly
ASKER
How do i get to the fields?
Data1.RecordSet.Fields("Ag e")
was the old way.
Data1.RecordSet.Fields("Ag
was the old way.
ASKER
I prefer to use an ODBC connection. i already have one made that worked previously..
How do i start an ODBC connection via code?
How do i start an ODBC connection via code?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you mean your ODBC DSN has already been setup? if so, all you have to do is:
assuming you called your DSN connection as dsnFoxPro
Dim oConn as New ADODB.Connection
oConn.Open dsnFoxPro
assuming you called your DSN connection as dsnFoxPro
Dim oConn as New ADODB.Connection
oConn.Open dsnFoxPro
Here is a good ADO tutorial to start with:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=12050
Leon
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=12050
Leon
ASKER
So that everyone (for future reference) knows how i got it to work:
REFERENCE: Microsoft ActiveX Data Objects 2.6
Dim rsConn as New ADODB.Connection
Dim rsRec as New ADODB.Recordset
rsConn.Open "Terms_Inventory" ' <--- That's my ODBC connection in the control panel
rsRec.Open "SELECT * FROM Inventory", rsConn, adOpenDynamic, adLockPessimistic
While Not rsRec.EOF
MsgBox(rsRec.Fields("Date" ))
rsRec.MoveNext
Wend
rsConn.Close
rsRec.Close
Set rsConn = Nothing
Set rsRec = Nothing
REFERENCE: Microsoft ActiveX Data Objects 2.6
Dim rsConn as New ADODB.Connection
Dim rsRec as New ADODB.Recordset
rsConn.Open "Terms_Inventory" ' <--- That's my ODBC connection in the control panel
rsRec.Open "SELECT * FROM Inventory", rsConn, adOpenDynamic, adLockPessimistic
While Not rsRec.EOF
MsgBox(rsRec.Fields("Date"
rsRec.MoveNext
Wend
rsConn.Close
rsRec.Close
Set rsConn = Nothing
Set rsRec = Nothing
Dim oConn as New ADODB.Connection
'the code below opens a connection to your foxpro database
'
oConn.Open "Provider=vfpoledb;" & _
"Data Source=C:\vfp8\Samples\Dat
"Mode=ReadWrite|Share Deny None;" & _
"Collating Sequence=MACHINE;" & _
"Password=''"
The Visual FoxPro OLE DB Provider is not installed by MDAC 2.x. You must install Visual FoxPro or download the OLE DB Provider
You also have to add Microsoft ActiveX Data Objects 2.6 Library to your References