Solved

Urgent - DSN Connection

Posted on 2002-04-22
4
137 Views
Last Modified: 2010-05-02
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(SQLQuery)
Do Until rsTitles.EOF = True
    List1.AddItem rsTitles.Fields("Name")
    rsTitles.MoveNext
Loop
End Sub
0
Comment
Question by:matherson_bill
4 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 300 total points
Comment Utility
Should it not be this:

Set dbVideo = OpenDatabase("video",dbDriverNoPrompt, True,"ODBC;DSN=Video")
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
If you have the driver, try to use ADO instead.
0
 
LVL 3

Expert Comment

by:n_narayanan
Comment Utility
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;Persist 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.OLEDB.4.0;Persist Security Info=False;Data Source=" & App.Path & "\LocalDB.mdb"

Cheers

Narayanan
0
 

Author Comment

by:matherson_bill
Comment Utility
It worked. Thanks Tim. Thanks everybody for the help.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now