Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB.Net Sql Connection Problem

Status
Not open for further replies.

bb9786

Programmer
Aug 20, 2009
3
US
Hi all,

I have a form that connects to a Sql Server 2005 database. I specify the connection string, but when the form opens it gives me a Microsoft .Net Framework error that says "Login failed for user 'OPERATIONS\xxxx'". The 'OPERATIONS\xxxx' is the user's Windows login id. My connection string specifies a login id and password for the sql database though. The program acts like it's bypassing the login info from the connection string and trying to connect using the user's Windows id.

Here's my connection string -

Dim ConnectionString As String = "Network Library=DBMSSOCN;Data Source=*server*,1433;Initial Catalog=*dbname*;User ID=*userid*;Password=*pwd*"

Dim cnAutoDB As New SqlConnection(ConnectionString)

This connection works for other programs that read from the same database. Also, if the user's Windows login id is added to the list of user's in the Sql database, it works fine. I'm perplexed. Any help would be greatly appreciated.
 
try adding Trusted_Connection=False; to the connection string.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Nope, that didn't work either. I'm getting the same error message.
 
My only thought would be to make sure you don't/didn't have a open connection to the SQL server in Server Explorer. If I remember right that will try to connect before anything else is done. Or have you stepped through and seen that it does hit your connection string before you get the error?

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
If you are using windows loging try removing the username and password and set "Integrated Security=True
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top