![]() |
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 |
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 |
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. |
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 |
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 |
All times are GMT +1. The time now is 12:25 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com