Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Use ADO to access SQL Database


Is it possible to setup an ADO connection to access a SQL 2000 database
from within VBA ?

Thanks


--
Silvertip
------------------------------------------------------------------------
Silvertip's Profile: http://www.excelforum.com/member.php...o&userid=28456
View this thread: http://www.excelforum.com/showthread...hreadid=480835

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Use ADO to access SQL Database

Silvertip,

Silvertip wrote:
Is it possible to setup an ADO connection to access a SQL 2000
database from within VBA ?


Yes, it's possible. There are a few options, including [Data | Import
External Data -- New Database Query...] and using the ADODB library via
code to execute SQL Server stored procs or run ad-hoc queries. For the
first option, it's pretty straightforward and wizard-based. The second
option will require some learning if you've never done it before. Google
"Excel" and "ADO" to get an idea of how to do this.

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]


  #3   Report Post  
Posted to microsoft.public.excel.programming
TK TK is offline
external usenet poster
 
Posts: 177
Default Use ADO to access SQL Database

Silvertip:

Try the following: example:

Remember:

'To use ADO objects in an application add a reference
'to the ADO component. From the VBA window select
'Tools/References< check the box
' "Microsoft ActiveX Data Objects 2.x Library"

Private Sub CommandButton1_Click()

' This declares everying in the procedure

Dim DB_NAME As String
Dim DB_CONNECT_STRING As String
Dim Cnn As ADODB.Connection
Set Cnn = New ADODB.Connection

'Fully quality the path to your database

DB_NAME = ("C:\Program Files\Microsoft Visual Studio\VB98\NWind.mdb")

DB_CONNECT_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & DB_NAME & ";" & ", , , adConnectAsync;"

' Open a connection using jet
Cnn.ConnectionString = DB_CONNECT_STRING
Cnn.Open

' Find out if the attempt to connect worked.

If Cnn.State = adStateOpen Then
MsgBox "Welcome to! " & DB_NAME, vbInformation, App_Name

Else
MsgBox "Sorry. No Data today."
End If

Good Luck
TK



"Jake Marx" wrote:

Silvertip,

Silvertip wrote:
Is it possible to setup an ADO connection to access a SQL 2000
database from within VBA ?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Use ADO to access SQL Database


aye - use www.connectionstrings.com


--
MattShoreson
------------------------------------------------------------------------
MattShoreson's Profile: http://www.excelforum.com/member.php...fo&userid=3472
View this thread: http://www.excelforum.com/showthread...hreadid=480835

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Use ADO to access SQL Database

Here is a good ADO reference...

http://www.erlandsendata.no/english/...php?t=envbadac
--
HTH...

Jim Thomlinson


"Silvertip" wrote:


Is it possible to setup an ADO connection to access a SQL 2000 database
from within VBA ?

Thanks


--
Silvertip
------------------------------------------------------------------------
Silvertip's Profile: http://www.excelforum.com/member.php...o&userid=28456
View this thread: http://www.excelforum.com/showthread...hreadid=480835


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
Update Excel Database via Access Main Database with a script Finnbar New Users to Excel 2 November 3rd 08 07:24 PM
Access Database John Excel Discussion (Misc queries) 0 August 29th 05 07:54 AM
Database Access Ernst Guckel[_4_] Excel Programming 3 May 3rd 05 09:13 AM
VBA Database access - How? Simon Sunke Excel Programming 3 January 23rd 04 12:24 PM
VBA Database access Simon Sunke Excel Programming 3 January 23rd 04 11:56 AM


All times are GMT +1. The time now is 05:44 PM.

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"