2012年3月22日星期四

Anybody help me !

When i use this connection string
"string myConnection = "Initial Catalog=Northwind;Data Source=localhost;Integrated Security=SSPI;";"
connect to database, i received massage :
----------
Server Error in '/asp_net/WebApplication1' Application.
Login failed for user 'TRANPHUC\ASPNET'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'TRANPHUC\ASPNET'.

Source Error:

Line 72: SqlCommand mySqlCommand = new SqlCommand(myInsertQuery); Line 73: mySqlCommand.Connection = mySqlClientSrvConn; Line 74: mySqlClientSrvConn.Open(); Line 75: //mySqlCommand.ExecuteNonQuery(); Line 76: mySqlCommand.Connection.Close();
------------
And when i use this string :
"string server_Con="server=localhost;uid=sa;pwd=;database=myData";
SqlConnection conn=new SqlConnection(server_Con);
conn.Open();
"
i received a massage:
-------
Server Error in '/asp_net/WebApplication1' Application.
Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Source Error:

Line 62: string server_Con="server=localhost;uid=sa;pwd=;database=myData"; Line 63: SqlConnection conn=new SqlConnection(server_Con); Line 64: conn.Open(); Line 65: } Line 66: public void InsertRow(string myConnection)

Source File: d:\asp_net\webapplication1\webform1.aspx.cs Line: 64
-------

What seem to be problem ? I can't connect to SQL server ! Help me !!!server=(local)

fyi.

And your sa.. has no password?|||check out www.connectionstrings.com

hth|||First case:
- you use thrusted autentication. This means you are using the same user account the web page runs under, to connect to your database (this is the ASP.NET user account). By default, it has no access to the SQL Server database. If you want it to have access, add it to the database logins

Second case:
- the password is blanc. Probably this is wrong...

没有评论:

发表评论