-
January 25th, 2009, 01:38 PM
#1
Connection String Blues
I'm learning SQL and how to access it from C#.
This is all on the same machine running XP Pro and .Net 2.0 - I've created a database in SQL Server Express and can manipulate it just fine from the SSMSE console. But when I try to open a connection to it in C# using the SqlConnection.Open() method it say's I'm "Not associated with a trusted SQL Server connection".
I've tried different things in the User Id and Password parameters in the connection string, including my PC login password and not using them at all (hoping it would take the default).
When I start up the SSMSE it lists the "User name" as "GEMINI\peter" (GEMINI is my PC) but if I use that in the connection string it just says GEMINI\peter is not associated with a trusted SQL Server connection.
How do I figure out what it wants? Thanks in advance!
-
January 25th, 2009, 02:06 PM
#2
Re: Connection String Blues
Can you post the connection string and the complete error message?
-
January 25th, 2009, 05:08 PM
#3
Re: Connection String Blues
Originally Posted by hspc
Can you post the connection string and the complete error message?
The error message varies slightly with the string but if I use my PC login (xxxx is not the real password) in the string -
"Data Source= GEMINI\\SQLEXPRESS;Initial Catalog=HWDB2;User Id=GEMINI\\peter;Password=xxxx"
I get
Exception: Message: Login failed for user 'GEMINI\peter'. The user is not associated with a trusted SQL Server connection.
Source: .Net SqlClient Data Provider
if I use no user id and password, hoping it will default to the current user (which is, after all, what SSMSE says it's using) . . .
"Data Source= GEMINI\\SQLEXPRESS;Initial Catalog=HWDB2;"
I get
Exception: Message: Login failed for user ''. The user is not associated with a trusted SQL Server connection.
Source: .Net SqlClient Data Provider
Note that GEMINI is the name of the PC.
-
January 25th, 2009, 09:53 PM
#4
Re: Connection String Blues
SQL server is probably using windows security - try this :
Code:
Data Source=GEMINI\\SQLEXPRESS;Initial Catalog=HWDB2;Integrated Security=True
Don't have any spaces between the '=' and the connection string.
Darwen.
-
January 26th, 2009, 02:20 AM
#5
Re: Connection String Blues
plnelson!
What happend to your problem ?
-
January 26th, 2009, 08:50 AM
#6
Re: Connection String Blues
Originally Posted by darwen
SQL server is probably using windows security - try this :
Code:
Data Source=GEMINI\\SQLEXPRESS;Initial Catalog=HWDB2;Integrated Security=True
Don't have any spaces between the '=' and the connection string.
Darwen.
THANKS!! That worked!
-
January 26th, 2009, 09:42 AM
#7
Re: Connection String Blues
Another satisfied customer. Ding ! Next please...
Darwen.
P.S. I'm glad it was something that simple...
-
January 26th, 2009, 10:55 PM
#8
Re: Connection String Blues
Originally Posted by darwen
P.S. I'm glad it was something that simple...
Until he tries it across a network whose machines don't share credentials..
Integrated Headache = True
-
January 27th, 2009, 02:40 PM
#9
Re: Connection String Blues
Originally Posted by cjard
Until he tries it across a network whose machines don't share credentials..
Yes, but:
- Windows authentication is the recommended mode because it is considered more secure
- Most enterprises now have domains that make credentials normally shared
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|