Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO Connect String to Pervasive

Status
Not open for further replies.

Rob7

Programmer
Dec 12, 2001
152
US
Hi All,
Just picked a client who is using Pervasive with no plan to change in the near future and I have to do some VB work for them. Does anyone have an ADO connect string that they would like to share? The one I have found on the Pervasive site will not work. This is what it looks like:

Dim con As New ADODB.Connection
Dim rstH As New ADODB.Recordset
Dim sConStr As String

con.Open "PROVIDER=MSDASQL;DSN=DEMODATA"
If con.State <> adStateOpen Then
Set con = Nothing
Set rstH = Nothing
MsgBox &quot;could not connect&quot;
End
End If

and it goes on. But the error i get is a compile error on the MSDASQL. Anyway, if anyone has one to share, I would really appreciate it. Working with MS SQL is so much easier.

Rob

 
For PSQL2000i -

Dim objCon As ADODB.Connection
Dim rs As ADODB.Recordset
Dim SQL As String

'Set up connection string
Tmp = GetINIString$(&quot;Data&quot;, &quot;DSN&quot;)
Set objCon = New ADODB.Connection
Set rs = New ADODB.Recordset
objCon.ConnectionString = Tmp

objCon.Open

SQL = &quot;Select * from OEORDlin_SQL where Loc ='&quot; & Trim(UserID) & &quot;'&quot;

rs.Open SQL, objCon


Jim
 
Thanks for the response Jim.
Is this: Tmp = GetINIString$(&quot;Data&quot;, &quot;DSN&quot;) a function that you wrote? It is erroring out on it. Also where are you getting the &quot;Data&quot; and &quot;DSN&quot; from?

Thanks

Rob
 
We using an INI file to load information to avoid hard coding. The function reads the INI file for the program. In this case this is returning the DSN Name or the DSN that point to your Macola DATA.
....INI
[DATA}
DSN=Macola_01

Jim
 
This is what I use. There are a bunch of ways to use it, but a good example is: create a parameter form in your app that contains setup values for the user. Enter the correct dsn for the user in the form by including a field called DSNname, link it to a data field or write it to a text file on the user's hard drive. Whenever your app opens the connection, read the value from the datafield and pass it to this procedure:

'in module header
Dim Macola as new ADO.Connection


Function OpenMacolaConnection(byval DSNname as string)

On Error GoTo OpenMacolaConnection_err

Macola.ConnectionTimeout = 120
Macola.Open &quot;Provider=MSDASQL;DSN=&quot;+DSNname
OpenMacolaConnection = True

Exit Function

'***********************
OpenMacolaConnection_err:
'***********************

MsgBox Str$(Err) + Error$

'use this value to handle failure in the calling proc
OpenMacolaConnection = False

End Function

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top