Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Connection String

Hi,

I am using the following connection string to run a number of SQL stored
procedures in Excel VBA

"ODBC;Driver={SQL
Server};Server=nae-is-sql1;Database=Database;Trusted_Connection=no;UID=U serID;pword=Password"

I have created a specific login account for UserID with a password, and
allowed it to run the necessary stored procedures, look at tables and look at
certain databases.

When I try to run my script, it keeps showing a dialogue box with the
Username of UserID and it keeps wanting me give it the password which I have
already specified, have I done something really silly here, I want this to be
a DNS less connection, I am using SQL Server 2000 and Excel version 2003.

Thanks PD
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Connection String

Phil,
One way to create/test connection strings is:
- Create a text file suitable. Rename it to "Whatever.udl".
- Double click this file. Enter the appropriate info. Test.
- When connection is successful, close and open the file in your favourite
text editor.

NickHK

"Phil" wrote in message
...
Hi,

I am using the following connection string to run a number of SQL stored
procedures in Excel VBA

"ODBC;Driver={SQL

Server};Server=nae-is-sql1;Database=Database;Trusted_Connection=no;UID=U serI
D;pword=Password"

I have created a specific login account for UserID with a password, and
allowed it to run the necessary stored procedures, look at tables and look

at
certain databases.

When I try to run my script, it keeps showing a dialogue box with the
Username of UserID and it keeps wanting me give it the password which I

have
already specified, have I done something really silly here, I want this to

be
a DNS less connection, I am using SQL Server 2000 and Excel version 2003.

Thanks PD



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Connection String

Hi Nick,

I tried to check my connection against what you suggested and I keep getting
an error of not a valid link file, futher to that I have been running some
profiler checks in SQL when I run the VBA code and it just ignores the
credentials that I have entered and just pass's in my network login details
that I use for my PC, and as I have SQL set up to Windows NT authenticate it
works, but will break if it is run from any other machine, here is my full
piece of code if it offers any more help.

Sub CollegeReport()

Worksheets("College AI Deployment").Activate
Range("A1:X50000").Select
Selection.Delete Shift:=xlUp

Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;Driver={SQL
Server};Server=Server1;Database=Database;Trusted_C onnection=no;UID=User;pword=pass" _
, Destination:=Range("A1"))
.CommandText = Array("select * from CCI2")
.Name = "Sheet1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=True
End With
Sheets("College AI Deployment").Select


End Sub


Thanks Phil



"NickHK" wrote:

Phil,
One way to create/test connection strings is:
- Create a text file suitable. Rename it to "Whatever.udl".
- Double click this file. Enter the appropriate info. Test.
- When connection is successful, close and open the file in your favourite
text editor.

NickHK

"Phil" wrote in message
...
Hi,

I am using the following connection string to run a number of SQL stored
procedures in Excel VBA

"ODBC;Driver={SQL

Server};Server=nae-is-sql1;Database=Database;Trusted_Connection=no;UID=U serI
D;pword=Password"

I have created a specific login account for UserID with a password, and
allowed it to run the necessary stored procedures, look at tables and look

at
certain databases.

When I try to run my script, it keeps showing a dialogue box with the
Username of UserID and it keeps wanting me give it the password which I

have
already specified, have I done something really silly here, I want this to

be
a DNS less connection, I am using SQL Server 2000 and Excel version 2003.

Thanks PD




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Connection String

Phil,

Try pwd for the password attribute name instead of pword.

ODBC;Driver={SQL
Server};Server=nae-is-sql1;Database=Database;Trusted_Connection=no;UID=U serID;Pwd=Password



--
Hope that helps.

Vergel Adriano


"Phil" wrote:

Hi,

I am using the following connection string to run a number of SQL stored
procedures in Excel VBA

"ODBC;Driver={SQL
Server};Server=nae-is-sql1;Database=Database;Trusted_Connection=no;UID=U serID;pword=Password"

I have created a specific login account for UserID with a password, and
allowed it to run the necessary stored procedures, look at tables and look at
certain databases.

When I try to run my script, it keeps showing a dialogue box with the
Username of UserID and it keeps wanting me give it the password which I have
already specified, have I done something really silly here, I want this to be
a DNS less connection, I am using SQL Server 2000 and Excel version 2003.

Thanks PD

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Connection String

Hi Vergel,

Thanks for that, I had just fixed it and was about to re-post, cant believe
how long that took to fix due to a sill syntax error.

Thanks again, Phil

"Vergel Adriano" wrote:

Phil,

Try pwd for the password attribute name instead of pword.

ODBC;Driver={SQL
Server};Server=nae-is-sql1;Database=Database;Trusted_Connection=no;UID=U serID;Pwd=Password



--
Hope that helps.

Vergel Adriano


"Phil" wrote:

Hi,

I am using the following connection string to run a number of SQL stored
procedures in Excel VBA

"ODBC;Driver={SQL
Server};Server=nae-is-sql1;Database=Database;Trusted_Connection=no;UID=U serID;pword=Password"

I have created a specific login account for UserID with a password, and
allowed it to run the necessary stored procedures, look at tables and look at
certain databases.

When I try to run my script, it keeps showing a dialogue box with the
Username of UserID and it keeps wanting me give it the password which I have
already specified, have I done something really silly here, I want this to be
a DNS less connection, I am using SQL Server 2000 and Excel version 2003.

Thanks PD



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 do I use a connection string? BrandenK Excel Discussion (Misc queries) 0 September 25th 07 07:10 PM
ADO connection string error?? Brent Excel Programming 2 April 3rd 07 07:56 PM
Can't get connection string right Frank Isaacs Excel Programming 1 October 2nd 03 05:02 AM
Can't get connection string right Brad Wood[_2_] Excel Programming 0 September 30th 03 09:38 PM
What is the connection string ? Jan Karel Pieterse Excel Programming 0 July 25th 03 11:37 AM


All times are GMT +1. The time now is 06:41 AM.

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"