Solved

RDO connect to server

Posted on 1998-11-10
3
657 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

930 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

13 Experts available now in Live!

Get 1:1 Help Now