ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Runtime error 91 when connecting to SQL Server 2000 (https://www.excelbanter.com/excel-programming/343203-runtime-error-91-when-connecting-sql-server-2000-a.html)

Jonas[_2_]

Runtime error 91 when connecting to SQL Server 2000
 
Hi

I have an Excel sheet that connects to a SQL Server and fetches data via
ADODB. It works fine on all machines but one, where I get the runtime error
91 at the last code line when creating the connection object.

Dim ADOCmd As New ADODB.Command
Dim ADOPrm As New ADODB.Parameter
Dim ADOCon As ADODB.Connection
Dim ADORs As ADODB.Recordset
Dim sParmName As String
Dim strConnect As String
Dim rStr As String

On Error GoTo ErrHandler

strConnect = CONNSTR

Set ADOCon = New ADODB.Connection

We have reinstalled MDAC 2.8 RTM, which is the same version used on the
machines where the code works. We have also tried to create a manual
database query from Excel (Data menu, Import External Data ...) which works
fine.

Any tips?

Brgds

Jonas



Vacation's Over

Runtime error 91 when connecting to SQL Server 2000
 
#1 suspect would be the ADO refernce not the same version

1 - option Explicit then debug

and / or

compare results on a "working" pc to the "non-working" pc
VBE ToolsRefernces

Checked Available refernces:

Microsoft ActiveX Data Objects 2.8 Library


"Jonas" wrote:

Hi

I have an Excel sheet that connects to a SQL Server and fetches data via
ADODB. It works fine on all machines but one, where I get the runtime error
91 at the last code line when creating the connection object.

Dim ADOCmd As New ADODB.Command
Dim ADOPrm As New ADODB.Parameter
Dim ADOCon As ADODB.Connection
Dim ADORs As ADODB.Recordset
Dim sParmName As String
Dim strConnect As String
Dim rStr As String

On Error GoTo ErrHandler

strConnect = CONNSTR

Set ADOCon = New ADODB.Connection

We have reinstalled MDAC 2.8 RTM, which is the same version used on the
machines where the code works. We have also tried to create a manual
database query from Excel (Data menu, Import External Data ...) which works
fine.

Any tips?

Brgds

Jonas





All times are GMT +1. The time now is 02:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com