Installed on My computer:
OS - XP Professional
IIS
1.1.Net Framework
MSDE
WebMatrix
Macromedia DreamWeaver MX
Having a Problem Connecting to my SQL Database using the following:void Button_Click(object sender, EventArgs e)
{
SqlConnection conNewstore;
string strInsert;
SqlCommand cmdInsert;conNewstore = new SqlConnection( "Server=(local);Integrated Security=SSPI;database=Newstore" );
strInsert = "Insert OrderPayment ( FullName, OrderID, CustomerID ) Values (@dotnet.itags.org.FullName, @dotnet.itags.org.OrderID, @dotnet.itags.org.CustomerID )";
cmdInsert = new SqlCommand( strInsert, conNewstore );
cmdInsert.Parameters.Add( "@dotnet.itags.org.FullName", FullName.Text );
cmdInsert.Parameters.Add( "@dotnet.itags.org.OrderID", OrderID.Text );
cmdInsert.Parameters.Add( "@dotnet.itags.org.CustomerID", CustomerID.Text );
conNewstore.Open();
cmdInsert.ExecuteNonQuery();
conNewstore.Close();
}
Please Note: if I change the connection string to this
conNewstore = new SqlConnection( "Server=(local);USER ID=sa;Password=Mypassword;database=Newstore" ); It works fine.But if I use this connection:conNewstore = new SqlConnection( "Server=(local);Integrated Security=SSPI;database=Newstore" ); It does not work
Any Help would be Great!! Thank You!
Here is the error message I receiveServer Error in '/NewStoreCS' Application.
Login failed for user 'MYNAME\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 'MYNAME\ASPNET'.
Source Error:
Line 14: cmdInsert = new SqlCommand( strInsert, conNewstore );
Line 15: cmdInsert.Parameters.Add( "@dotnet.itags.org.FullName", txtFullName.Text );
Line 16: conNewstore.Open();
Line 17: cmdInsert.ExecuteNonQuery();
Line 18: conNewstore.Close();Source File: C:\Inetpub\wwwroot\NewStoreCS\InsertPage.aspx Line: 16
Stack Trace:
[SqlException: Login failed for user 'MYNAME\ASPNET'.]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +474
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
ASP.InsertPage_aspx.Button_Click(Object sender, EventArgs e) in C:\Inetpub\wwwroot\NewSToreCS\InsertPage.aspx:16
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
Since you are using "Integrated Security=SSPI", the login credentials for the ASPNET user are used to log into the SQL Server. If you want to use this integrated security you need to create a MYNAME\ASPNET account in SQL Server and give it the proper permissions.
Thank you.
Do you know where I can read (find info) on how to do this? Thanks again.
0 comments:
Post a Comment