Hello anyone :cheesy: ,

I am really new in programming with C# and know very little about it. Currently i am doing a asp website for my company as i am on a school attechment. No one here can help me. I am suspose to do a helpDesk website for my company and i am stuck at the log in page already.

I am suspose to connect to a remote PC(server) MSSql7 Database within the same LAN but i cant make my codes work as they kept giving me this error

"An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code
Additional information: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection."

I really do not know where go wrong, could it be my connectionString?

"conn.ConnectionString = "Data Source=192.168.90.10;Initial Catalog=HD_test;UID=username changed;PWD=password changed;Trusted_Connection=yes;";

Aubrey
Cheers =D
"

Hi there,

Just for future reference, please make sure your connection string doesn't contain sensitive information like usernames and passwords. I took the liberty of editing out the user name and password from the string.

But, given your issue, it doesn't sound like permissions are set properly on your database server. As such, that's not so much of a C# issue, but more of a server configuration issue.

Looking at the connection string, though, what database server are you using for your backend? I know on SQL Server, you use "User ID=foo;Password=bar" in your connection string, rather than "UID=foo;PWD=bar". It could be different depending on the type of database. Like, an ODBC connection string might be different from a SQL connection string. Since you mentioned MSSQL server, you might just need to change that.

try getting rid of the Trusted_Connection that has always led me to problems when logging in without intergrated security.
And try the newer format for the connection string, below is the one i ripped quick out of one old sites which worked

string connectionString= 
				@"Data Source=srvername or ip" + 
				@";Initial Catalog=database" +
				@";User Id=username" + 
				@";Password=passwrd";

Ok i will take the user id and password out, but where do i put them if they requires the userid and password.

I use enterprise manager to access to my database at the server.

no dont take out the username and password.
just take out "Trusted_Connection=yes;";"

and use the connection string i showed you
UID is now User Id
PWD is now Password
etc...

SQL Connections string

Network Library=DBMSSOCN;Data Source=192.168.90.10,1433;database=Northwind;User id=;Password=;
This article has been dead for over six months. Start a new discussion instead.