Friday, February 24, 2012

Cannot connect to SQL Server on different machine

Hello, I know this has been covered many times but I just can't get an answer that applies to my situation.
- SQL Server is on different machine.
- I need to connect to SQL Server with SQL authentication. (Not a Windows account)
- I CAN connect through Server Explorer as the user specified by the database administrator.
- I CAN run stored procedures through the Query Analyzer as the user specified by the database administrator.
- I CANNOT connect by the browsing ASP.NET application
I have tried the connection string in the Web.Config and at the page level but keep getting messages such asLogin failed for user 'User' or sometimes "Not associated with a trusted Connection"
In Web.Config I have:<authenticationmode="None"/>

On the page I have:
Dim strConnAsString = "database=servername;initial catalog=databasename;user id=User;password=password"
Dim connAsNew SqlConnection(strConn)
conn.Open()
I always get an error at conn.Open()
I have spent too many hours playing around with this - any suggestions?? Please!!
By telling it to connect asUser the ASPNET account does not have to be created in SQL Server correct?
Thanks for any help!!

Your connection string is specifying that you should connect using a trusted connection. You have to have this in your connection string:

Trusted_Connection=false;

If you are ever in doubt about the connection string, then try refer to this site:

www.connectionstrings.com

Cheers,

Justin

|||

Thanks for your reply, but this did not make a difference.

I put in a Response.write to show the identy and it displayed "machinename\ASPNET"
but my error message is displaying "Login failed for user'User'.
I needUser to log into the SQL Server.
Will I have to makeUser a windows account and then impersonate it to access the SQL Server?
- ASPNET is not in SQL Server as we want to connect withUser
I've checked out connectionstrings.com, but I think my problem is more of an account issue.
Thanks.

No comments:

Post a Comment