Hi

it's getting frustrated.

I tried to use Excel 2007 to extract data from SQL Server 2008 R2.

But I think it fails to connect to the server.

>From Excel 2007, connection from data tab, I can access to the server
and get data. the following is the connection string I got from the
property.

Provider=SQLOLEDB.1;Persist Security Info=True;User
ID=ReadingEggTeam;Data Source=reportsrv;Use Procedure for
Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=MSERVER-
DELL;Use Encryption for Data=False;Tag with column collation when
possible=False;Initial Catalog=ReadingEggTracking

>From a book called 'Wrox Excel 2007 VBA Programmers Reference', I
tried to do the following below and I get an error at
"rsData.Open sSQL, sConnect, adOpenForwardOnly, adLockReadOnly,
adCmdText"

Dim rsData As ADODB.Recordset
Dim sConnect As String
Dim sSQL As String

' Create the connection
sConnect = "Provider=SQLOLEDB;" & _
"Data Source=ReportSrv\report; Initial Catalog= ReadingEggTracking;" &
_
"User ID=ReadingEggTeam; Password=1234;" & _
"Network Library=dbmsscon"

sSQL = "SELECT * from TrialTracking;"

' Create the Recordset object and run the query.

Set rsData = New ADODB.Recordset

rsData.Open sSQL, sConnect, adOpenForwardOnly, adLockReadOnly,
adCmdText




Then I tried to use the connection string I got it from the connection
property. It didn't work.


I think there is something wrong with connection string. Can you tell
me what it is wrong pleasE?

I can not figure it out... T T;;

cheers

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

Reply via email to