Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.querydao,microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default connect to sql

Excel 2000, 2003

I've built an app that connects to sql and does various things. On some
machines it works just fine, on other machines it throws an error. The
error occurs when I attempt to connect to sql. The error is:
Run-time error '-2147467259 (80004005)';
Automation error
Unspecified error


My connection code is below.
Sub Connect()

Set rs = New ADODB.Recordset
Set cn = New ADODB.Connection
sADOConnect = "DSN=MyDSN;UID=MyUID;PWD=MyPwd"

With cn
.CursorLocation = adUseClient
.ConnectionString = sADOConnect
.ConnectionTimeout = 180
.CommandTimeout = 180
.Properties("Prompt") = adPromptCompleteRequired
.Open
End With

End Sub

Can anyone tell me what is causing this error, and how I can get around it?

Thanks, Andre


  #2   Report Post  
Posted to microsoft.public.excel.querydao,microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default connect to sql

Missing drivers?

Tim

--
Tim Williams
Palo Alto, CA


"Andre" wrote in message
...
Excel 2000, 2003

I've built an app that connects to sql and does various things. On some
machines it works just fine, on other machines it throws an error. The
error occurs when I attempt to connect to sql. The error is:
Run-time error '-2147467259 (80004005)';
Automation error
Unspecified error


My connection code is below.
Sub Connect()

Set rs = New ADODB.Recordset
Set cn = New ADODB.Connection
sADOConnect = "DSN=MyDSN;UID=MyUID;PWD=MyPwd"

With cn
.CursorLocation = adUseClient
.ConnectionString = sADOConnect
.ConnectionTimeout = 180
.CommandTimeout = 180
.Properties("Prompt") = adPromptCompleteRequired
.Open
End With

End Sub

Can anyone tell me what is causing this error, and how I can get around

it?

Thanks, Andre




  #3   Report Post  
Posted to microsoft.public.excel.querydao,microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default connect to sql

At first, yes. But the error persists even after installing the latest
version of MDAC.


  #4   Report Post  
Posted to microsoft.public.excel.querydao,microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default connect to sql


you make yourself vulnerable to installation issues by using DSN.
If the DSN is not on the user's machine it will bomb.

Probably better to fully specify the connection string in your code
and avoid the use of DSN altogether.

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Andre wrote :

At first, yes. But the error persists even after installing the
latest version of MDAC.

  #5   Report Post  
Posted to microsoft.public.excel.querydao,microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default connect to sql

I would second keepITcool's advice: better to go with DSN-less connection.



--
Tim Williams
Palo Alto, CA


"keepITcool" wrote in message
. com...

you make yourself vulnerable to installation issues by using DSN.
If the DSN is not on the user's machine it will bomb.

Probably better to fully specify the connection string in your code
and avoid the use of DSN altogether.

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Andre wrote :

At first, yes. But the error persists even after installing the
latest version of MDAC.





  #6   Report Post  
Posted to microsoft.public.excel.querydao,microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default connect to sql

Ok, thanks for the suggestion. Do you have any good links that show an
example of a dsn-less connection?

Thanks, Andre


  #7   Report Post  
Posted to microsoft.public.excel.querydao,microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default connect to sql

http://www.connectionstrings.com/

--
Tim Williams
Palo Alto, CA


"Andre" wrote in message
...
Ok, thanks for the suggestion. Do you have any good links that show an
example of a dsn-less connection?

Thanks, Andre




  #8   Report Post  
Posted to microsoft.public.excel.querydao,microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default connect to sql

What a great site - thanks. I'll give dsn-less a try and see if it resolves
my problem.

Andre


  #9   Report Post  
Posted to microsoft.public.excel.querydao,microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default connect to sql

Dsn-less worked - at least on one computer where it had previously failed.
I'll test the others next week, but I'm very optimistic. Thanks all for
your help/suggestions.

Andre


  #10   Report Post  
Posted to microsoft.public.excel.querydao,microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default connect to sql

"Andre" wrote in message
...
At first, yes. But the error persists even after installing the latest
version of MDAC.


I have the same problem which I cannot resolve, what drivers do I need ?

Sub Testing()
Dim cmdCommand As New ADODB.Command
Dim recSet As New ADODB.Recordset
Dim cn As New ADODB.Connection

cn.ConnectionString =
"Server=dimension9150;Database=IPS;Trusted_Connect ion=True"
cn.Open

cmdCommand.ActiveConnection = cn
cmdCommand.CommandText = "GetMonitors"
cmdCommand.CommandType = adCmdStoredProc

Set recSet = cmdCommand.Execute
Debug.Print recSet(0)
recSet.Close

End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Connect PC to UNIX via TCP/IP [email protected] Links and Linking in Excel 0 January 20th 07 09:34 PM
Excel cannot connect to web Ltat42a Excel Discussion (Misc queries) 0 May 29th 06 05:18 PM
connect to MS SQL mk Excel Programming 1 April 3rd 05 08:35 PM
connect to an oracle db b geber Excel Programming 1 February 4th 05 07:27 PM
SQL Connect Soniya[_3_] Excel Programming 2 January 31st 05 07:39 AM


All times are GMT +1. The time now is 12:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"