Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2006
    Posts
    2

    Question Unanswered: Using an ODBC on a remote server

    Hi folks...

    I'm trying to do something pretty simple, namely access a database on another machine on our network using ADODB in VB6. I can't find any documented examples of this. If I use "server=<name>" it doesn't complain about the syntax, but just says the data source cannot be found. The code I have does work if I run it on the machine local to the database. However, as I'm trying to access two (proprietary) databases on two different machines, I'm currently hosed... Some guidance would be appreciated.

    Thanks!

    Alan

  2. #2
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    It's difficult to show you what's wrong if you don't show us the code you're using, and provide us with more information. (database type, for instance.)

    THat being said, this is a decent ADO Tutorial.
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


  3. #3
    Join Date
    Apr 2006
    Posts
    2
    Sorry about that... My question is pretty generic - How do you get ADODB to work remotely? Unfortunately the link you kindly provided (for which my thanks) didn't cover this. Anyway, here's my code:

    Private Const sCnnString = "DSN=PSExpEvent;UID=m440;PWD=4w558rth;" _
    & "Server=exptest2;RedundantLAN=0;RedundantCPU=0 "

    Public Function CollectEvents(ByVal sEventSourceName As String, ByVal colParameters As Collection, Optional ByVal dtStartDate As Date = #12:00:00 AM#, Optional ByVal dtEndDate As Date = #12/31/9999#) As ADODB.Recordset

    Dim rs As New ADODB.Recordset
    Dim cnn As New ADODB.Connection

    cnn.ConnectionTimeout = 30
    cnn.Open sCnnString
    End Function

    The DSN is pointing to an in-house database, which I can't readily install on the local machine. Is there some expectation with ADODB that it can only pick up the database configuration it needs from the local machine, and can't get this from the actual server?

    Thanks,

    Alan

  4. #4
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    Is there some expectation with ADODB that it can only pick up the database configuration it needs from the local machine, and can't get this from the actual server?
    Not at all.

    You need to know the database type (Oracle, SQL Server, Etc.)

    Ref Carl Prothman's Connection String Site for details of building a connection string.

    The only thing you would need to do differently, in the link I pointed you earlier, is to build a connection string that specifies a remote server (or file)

    Ref the DSN you indicate in your connection string. Are you able to connect to the database using this DSN with other apps?
    Last edited by loquin; 04-20-06 at 15:40.
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •