Results 1 to 8 of 8

Thread: SQL Server Connection Question

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Posts
    82
    We just delivered our first VB6-SQL Server app. The client reports the following error when opening the connection:

    [Microsoft][ODBC Driver Manager]Data source name not found and no default driver specified

    We declare the following in the sub main():

    Public MyConnection As New ADODB.Connection

    Our connection code look like this:

    Code:
        With MyConnection
            .ConnectionString = "  Driver={SQL Server};" _
                                & "server=" & sServername & ";" _
                                & "Database=" & sDatabase & ";" _
                                & "uid=" & sUserID & ";" _
                                & "pwd=" & sPasswd
            .Open
        End With
    His email to me states:
    "I have the DNS set up properly, I don't know if there is something in the code pointing somewhere?"

    Can anyone help???

    Thanks

  2. #2
    Addicted Member PsudoLogical's Avatar
    Join Date
    Dec 2000
    Location
    Upstate N.Y.
    Posts
    144
    Try this code... it was generated on an ADO Data control. Actually what I did was to copy the string that was generated... the following... and code it into my app as I didn't want to use a data control.... I hope this works for you

    Provider=MSDASQL.1;Persist Security Info=False;Extended Properties="DRIVER=SQL Server;SERVER=SQL-SERVER;APP=Visual Basic;WSID=WorkstationId;Trusted_Connection=Yes"

  3. #3
    Junior Member
    Join Date
    Oct 2000
    Location
    High Wycombe, UK
    Posts
    25
    Jeff,

    I assume that you are trying to connect to SQL Server using the OLE DB Provider for SQL Server and not via a DSN or DSNLess connection.

    If this is so then you need to specify a provider such as SQLOLEDB. The connection string should look like this:

    cn.connectionstring = "PROVIDER=SQLOLEDB" & _
    ";SERVER=" & sServer & _
    ";UID=" & sLoginID & _
    ";PWD=" & sPassword & _
    ";DATABASE=TCW"
    cn.open

    Hope this helps

    Gary
    Ciao.........Gary

    VB6, SQL Server 7, Access 97

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Posts
    82
    Thanks, Gary-

    In his email to me he said "I have the DNS set up properly...". Should I have him remove the DNS?

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Posts
    82
    PsudoLogical:

    You're code works on this end. Thanks. I'll upload it to my client. Let you know results tomorrow.

  6. #6
    Junior Member
    Join Date
    Oct 2000
    Location
    High Wycombe, UK
    Posts
    25
    Jeff,

    If you mean can he remove the entry for the DSN in the ODBC Data Source Administrator via Control Panel then yes.

    Ciao

    Gary
    Ciao.........Gary

    VB6, SQL Server 7, Access 97

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Posts
    82

    New Problem!

    Thanks to all. Problem 1 solved, Problem 2 is at hand.

    PsudoLogical, your connection code seems to work. Thanks very much. However, now my client reports the following error:

    Error 430
    Class does not support automation or does not support expected interface.

    The code he is executing is:
    Code:
    Dim rsTestKey As New ADODB.Recordset
        
    g_sSQL = "SELECT * FROM tblKeys WHERE sKeyLine='" & lblKeyLine & "'"
    rsTestKey.Open g_sSQL, PROJ_DB, adOpenKeyset, adLockPessimistic, adCmdText
    Anyone want to guess? He's running the app on an NT 4 box. Could DCOM or MDAC be at fault? Are they normally in NT or what? Thanks very much.

  8. #8
    Addicted Member PsudoLogical's Avatar
    Join Date
    Dec 2000
    Location
    Upstate N.Y.
    Posts
    144
    My first 'guess' is that the version of MDAC running on your client machine is ver 2.0.... I am running 2.5 on Win2K Pro.... Let me know if this is true or not


    Regards

Posting Permissions

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



Click Here to Expand Forum to Full Width