Groups | Blog | Home
all groups > sql server connect > october 2004 >

sql server connect : Problem Connecting to MSSQL2000 from VB6 via ODBC


andy NO[at]SPAM newlinecomputing.com
10/6/2004 9:14:45 AM
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")



Sue Hoegemeier
10/6/2004 5:53:09 PM
You can get rid of the workspace and dbengine as that's used for
Jet/Access databases.
You can find ADO connections strings using ODBC and SQL Server at:
http://www.able-consulting.com/MDAC/ADO/Connection/ODBC_DSNLess.htm#ODBCDriverForSQLServer

-Sue

[quoted text, click to view]
AddThis Social Bookmark Button