Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Working with ADO to connect to SQL database


Hi,

I would appreciate any snippets of code that show an example of how t
connect to a Microsoft SQL database using ADO. The examples I've see
in various books don't specify the login user name, password, and als
don't specify the table name. Maybe I haven't found the right ones.
Most of them are geared toward MS Access database. Thanks


-
veritasc
-----------------------------------------------------------------------
Posted via http://www.mcse.m
-----------------------------------------------------------------------
View this thread: http://www.mcse.ms/message566438.htm

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Working with ADO to connect to SQL database

Hello,

For a nice list of OLEDB connection strings see the following

http://www.able-consulting.com/MDAC/...derForSQLServe

Also, Dan has a nice example here

http://mrexcel.com/board2/viewtopic.php?t=53716&start=

Regards
Nate Oliver
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 459
Default Working with ADO to connect to SQL database

Here are some connection string samples, including SQL Server:

http://www.able-consulting.com/MDAC/...erForSQLServer

Note you do not specify tables in the connection string; rather you
execute the SQL you would normally use in Query Analyzer against the
ADO connection.

--

veritasca wrote in message ...
Hi,

I would appreciate any snippets of code that show an example of how to
connect to a Microsoft SQL database using ADO. The examples I've seen
in various books don't specify the login user name, password, and also
don't specify the table name. Maybe I haven't found the right ones.
Most of them are geared toward MS Access database. Thanks.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Working with ADO to connect to SQL database


Nate Oliver wrote:
*Hello,

For a nice list of OLEDB connection strings see the following:

http://tinyurl.com/80qj

Also, Dan has a nice example he

http://mrexcel.com/board2/viewtopic.php?t=53716&start=6

Regards,
Nate Oliver *


__________
Thanks, Nate.

I used Dan's nice example and got to by database connection but faile
when it tries to open the recordset, please see below:

---------
Dim adoCN As ADODB.Connection, adoRS As ADODB.Recordset
Dim strSQL As String
Set adoCN = New ADODB.Connection

adoCN.Open "Provider=sqloledb;" & _
"Data Source=DemoSQL;" & _
"Initial Catalog=template_template1backup2_db0;" & _
"User Id=User01;" & _
"Password=Snno4"

Set adoRS = New ADODB.Recordset

strSQL = "SELECT * FROM RUN"

'Open the recordset
adoRS.Open strSQL, adoCN, adOpenForwardOnly, adLockReadOnly

--------
It failed right at this last statement with a pop-up Error message
Run-time error '-2147217865(80040e37) Automation Error
How do I debug this??? Your help is appreciated. Thanks


-
veritasc
-----------------------------------------------------------------------
Posted via http://www.mcse.m
-----------------------------------------------------------------------
View this thread: http://www.mcse.ms/message566438.htm

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Working with ADO to connect to SQL database

Sorry to just jump in, but I'm getting this exact same error whil
trying to connect to a SQL 2000 db.

Was the issue resolved? If so, how did you make it work?

Thanks

--
Message posted from http://www.ExcelForum.com

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
How to connect excel(If I consider it as a database) with a websit SATABDI NATH Excel Discussion (Misc queries) 0 July 8th 08 12:34 PM
How to connect to database? Eric Excel Worksheet Functions 3 July 25th 07 12:55 PM
connect to access database and run a query in excel VBA Bob Excel Discussion (Misc queries) 0 April 25th 06 08:12 PM
connect a form to excel database Kathy Excel Discussion (Misc queries) 5 October 10th 05 06:17 AM
How to connect to Informix database using ADO??? Mlaky[_2_] Excel Programming 2 February 12th 04 08:56 AM


All times are GMT +1. The time now is 12:37 PM.

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

About Us

"It's about Microsoft Excel"