matherson_bill
asked on
Urgent - DSN Connection
Hello. In the following example, to open an Access DB I use the following statement: Set dbBiblio = OpenDatabase(C:\video.mdb) . This works fine but the problem is that I dont want to use Access but Pervasive 2000.(It is a RDBMS similar to SQL Server). So, I made my Pervasive DB, then I made a machine data source and I named it "video". Finally I'm trying to open my Pervasive DB like this: Set dbBiblio = OpenDatabase(video). The problem is that it doesn't open automatically. When I run the application I first receive a "Select Data Source" window,then I select "video" DSN and then it runs. How can I connect without having to choose my DSN from the prompt window?
Dim dbVideo As Database
Dim rsTitles As Recordset
Private Sub Command1_Click()
List1.Clear
SQLQuery = "Name LIKE '*" & Text1 & "*'"
rsTitles.FindFirst SQLQuery
If rsTitles.NoMatch = True Then Exit Sub
List1.AddItem rsTitles.Fields("Name")
Do Until rsTitles.NoMatch = True
rsTitles.FindNext SQLQuery
List1.AddItem rsTitles.Fields("Name")
Loop
End Sub
Private Sub Form_Load()
Set dbVideo = OpenDatabase(video)
SQLQuery = "SELECT * FROM Customers"
Set rsTitles = dbVideo.OpenRecordset(SQLQ uery)
Do Until rsTitles.EOF = True
List1.AddItem rsTitles.Fields("Name")
rsTitles.MoveNext
Loop
End Sub
Dim dbVideo As Database
Dim rsTitles As Recordset
Private Sub Command1_Click()
List1.Clear
SQLQuery = "Name LIKE '*" & Text1 & "*'"
rsTitles.FindFirst SQLQuery
If rsTitles.NoMatch = True Then Exit Sub
List1.AddItem rsTitles.Fields("Name")
Do Until rsTitles.NoMatch = True
rsTitles.FindNext SQLQuery
List1.AddItem rsTitles.Fields("Name")
Loop
End Sub
Private Sub Form_Load()
Set dbVideo = OpenDatabase(video)
SQLQuery = "SELECT * FROM Customers"
Set rsTitles = dbVideo.OpenRecordset(SQLQ
Do Until rsTitles.EOF = True
List1.AddItem rsTitles.Fields("Name")
rsTitles.MoveNext
Loop
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you have the driver, try to use ADO instead.
I am giving you an example with respect to SQL Server and MS Access using ADO OLE DB, you can use the same (by changing the provider name).
Dim con As New ADODB.Connection
con.Open ("Provider=SQLOLEDB.1;Pers ist Security Info=False;User ID=" & strUser & ";Password=" & strPWD & ";Initial Catalog=" & strDB & ";Data Source=" & strServer)
Same way for MS ACCESS
Dim conLocal As New ADODB.Connection
conLocal.Open "Provider=Microsoft.Jet.OL EDB.4.0;Pe rsist Security Info=False;Data Source=" & App.Path & "\LocalDB.mdb"
Cheers
Narayanan
Dim con As New ADODB.Connection
con.Open ("Provider=SQLOLEDB.1;Pers
Same way for MS ACCESS
Dim conLocal As New ADODB.Connection
conLocal.Open "Provider=Microsoft.Jet.OL
Cheers
Narayanan
ASKER
It worked. Thanks Tim. Thanks everybody for the help.