Solved

Urgent - DSN Connection

Posted on 2002-04-22
4
138 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
ID: 6959594
Should it not be this:

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

Expert Comment

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

Expert Comment

by:n_narayanan
ID: 6959640
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
ID: 6960547
It worked. Thanks Tim. Thanks everybody for the help.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA Shell can't Find Word document 11 114
Recommendation vb6 to vb.net or others 14 178
Child Form in front 4 49
VB 6 error 5 in windows 10 but not in XP 7 63
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

830 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