Solved

RDO connect to server

Posted on 1998-11-10
3
669 Views
Last Modified: 2008-02-01
The following problem persists... since I'm rather new to ODBC and RDO, I hope you will be able to help me. I'm trying to connect to a db on a ODBC server. The following code will do so, if the db is on the development computer.

    Set cnDays = New rdoConnection
    With cnDays
    .Connect = "uid=;pwd=;dsn=sbqvtest;"
    .CursorDriver = rdUseOdbc
    .EstablishConnection rdDriverNoPrompt, True
    Do While .StillConnecting
        DoEvents
    Loop
    End With

So the DSN is defined on my computer (Scratchy). However, if I want to connect to a db on a different computer (i.e. Quimby), how do I do so. Trying the following always gives me a "DSN not found, etc" error

    Set cnDays = New rdoConnection
    With cnDays
    .Connect = "Server=quimby;uid=;pwd=;dsn=sbqv_test_2;"
    .CursorDriver = rdUseOdbc
    .EstablishConnection rdDriverNoPrompt, True
    Do While .StillConnecting
        DoEvents
    Loop
    End With

If I set the prompt variable to 0, it prompts me for a data source, but on MY computer, not on the specified server...
The DB is an access driver, specified as a system DSN. All computers are on the same network, but the goal is to access it over the Inet...
Thanks in advance
0
Comment
Question by:lbk
3 Comments
 

Expert Comment

by:umzilber
ID: 1444142
ODBC already makes a connection to the server,  What you are trying to do defeats the purpose.

try to redo ODBC declaration in WINNT/WIN95 to point to the DB on Quimby and when you make a connection to RDO the location of the DB will be transparent and first version of the source will work just fine
0
 
LVL 1

Author Comment

by:lbk
ID: 1444143
I'm not sure I'm following you. As I undetrstand now the problem with your solution is, that I don't want to use ODBC on the local machine. I want to run the control in IE on any random computer that has or doesn't have ODBC running. The control should then connect to quimby. The fact that it works with a local ODBC source is meaningless, other than for me to say that the code works on a local basis, but once the control is distributed, ODBC won't be available on the local machine
0
 
LVL 1

Accepted Solution

by:
mmahdi earned 100 total points
ID: 1444144
Hi,

If you get a DSN not found error on another machine, means the DSN entry for that specific ODBC connection in the client machine is not present in which case you can register it at run-time using the following:

Put the following function in a module:

Private Sub RegisterDataSource()

Dim en As rdoEnvironment
Dim cnTest As rdoConnection
Dim strAttribs As String

' Build keywords string.
strAttribs = "Description=" & "DSN Test" & Chr$(13) & "OemToAnsi=No" & Chr$(13) & "SERVER=SERVERNAME" & Chr$(13) & "Network=(Default)" & Chr$(13) & "Database=DATABASENAME" & Chr$(13) & "Address=(Default)"  
' Create new registered DSN.
rdoEngine.rdoRegisterDataSource "DSN Test", "DSN Test", True, strAttribs

replace the variables SERVERNAME and DATABASENAME with your own values respectively.

When you load the form call the function RegisterDataSource to register the DSN. If the DSN is already registered nothing will happen.

I hope this will help.



Cheers
MMAHDI
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…

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