Problem Connecting to MSSQL2000 from VB6 via ODBC

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Andy (andy_at_newlinecomputing.com)
Date: 10/06/04

  • Next message: Brian Piotrowski: "Connection to an iSeries (AS/400) DB"
    Date: 6 Oct 2004 09:14:45 -0700
    
    

    Please can somebody help me.

    I am developing a VB6 application connecting to a SQL Server 2000
    database,
    which at the moment is on my local machine.

    The code below loooks as though it should work but when I get
     to the openconnection statement I get a runtime error 13 "Type
    Mismatch"
    and the connection to the databse fails.

    My ODBC driver is setup correctly, as is the permissions on the sql
    server itself.

    Can anybody see what I am doing wrong.

    thanks in advance

    Option Explicit

    Private Sub getdata_Click()

    Dim wspodbc As Workspace
    Dim conNewConnection As Connection
    Dim rstodbc As Recordset
    Dim wrkspc As String

    wrkspc = "ODBCWRK"
    Set wspodbc = dbengine.createworkspace(wrkspc, "name", "password",
    dbuseodbc)

    Set conNewConnection = wspodbc.OpenConnection("connection1",
    dbDriverComplete, False, _
                           
    "ODBC;database=DB1;UID=name;PWD=password;DSN=DBCONN1")

    End Sub


  • Next message: Brian Piotrowski: "Connection to an iSeries (AS/400) DB"

    Relevant Pages

    • Re: connection to sql server 2005 problem
      ... If one is not careful when installing SQL Server Express, it can result in one or more of the SQL Server related services being shut down when it is not in use. ... Dim _con = New SqlConnection("Initial Catalog=lion;Data ... This illustrates retrying with a delay until either, a connection is made or 3 attempts have been made, whichever occurs first. ... Public Function login(ByVal un As String, ...
      (microsoft.public.dotnet.languages.vb)
    • DAO ODBC connetion to sql server with access logon
      ... I have an access front end, and I got one sql server tabel that I ... connect to using a linked connection using ODBC. ... Dim SQLws As DAO.workspace ...
      (microsoft.public.access.security)
    • RE: Excel VBA & ODBC Data Sources
      ... The following is a routine I use to extract data from a SQL Server database ... Dim cn As New ADODB.Connection ... Dim CombinedArrayAs String, FieldNamesAs String ... Here is my connection string in VBA: ...
      (microsoft.public.excel.programming)
    • Re: Saving Blob Data To File
      ... This is the sample code from msdn on how to save image to database. ... ' The SQL Server Image datatype is a binary datatype. ... Dim ms As New MemoryStream ... ' This only needs to be done the very first time a connection ...
      (microsoft.public.dotnet.languages.vb)
    • Re: Update sql server table with dataset from xls file
      ... Create another adapter for the sQL Server table. ... > ' Create connection string variable for excel. ... > Dim objConn As New OleDbConnection ...
      (microsoft.public.dotnet.framework.adonet)