?
Solved

Urgent - DSN Connection

Posted on 2002-04-22
4
Medium Priority
?
141 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 1200 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

801 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