tags:

views:

55

answers:

1

how can i connect win nt sqlexpress? i am using this code to connect.it works with any version and kind of sql.

internal string GetConnectionString() 
{ 
      return "Data Source=" + "MyPC\SQLExpress" + 
              ";Initial Catalog=Master;User ID=" + username + 
              ";Password=" + password; 
}

when connectiong with express ===>>>

Login failed for user 'NT AUTHORITY'. The user is not associated with a trusted SQL Server connection.

or

Login failed for user 'sa'. The user is not associated with a trusted SQL Server connection.

or

Login failed for user 'sysadmin'. The user is not associated with a trusted SQL Server connection.

+3  A: 

You need to add the following to the connection string:

Trusted_Connection=yes;

If you are trying to use windows credentials you will need to set:

Integrated Security=true;

This will use Windows authentication rather than SQL authentication. If you don't spesify a user name and password, the currently logged in user will be used implicitly.

See http://www.connectionstrings.com/sql-server-2005 for more details.

DLKJ
thanks a lot!!!
Behrooz