Answered by:
Mobile web application data access problem

Question
-
User1231419363 posted
My mobile web application using aspx cannot access from localhost.
It prompt msg as below when i manually open internet explorer and key in the path "http://localhost/myapplication/default.aspx" when i try to access sql server 2005 data.
But when i use debug function in visual studio 2005 to open the application, data from sql server 2005 can be accessed & shown.
can anyone let me know what is my problem?
thanks.
<------
Login failed for user 'USER-1221\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 'USER-1221\ASPNET'.
Source Error:
Line 24:
Line 25: Dim sql As String = "SELECT * FROM project"
Line 26: sqlConn.Open()
Line 27:
Line 28: Dim da As SqlDataAdapter = New SqlDataAdapter(sql, sqlConn)
Monday, April 30, 2007 1:33 PM
Answers
-
User1634317999 posted
It seems that the ASPNET account has no permission to access the SQL Server.
This Knowledge Base article might help you.
If you debug the application with Visual Studio are you using IIS or the built in Development Server? The Dedevelopment Server might run in another security context as IIS which has sufficient permissions to access the database server.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, May 1, 2007 3:43 AM
All replies
-
User1634317999 posted
Are you using the correct connection string? Do you have specified user name and password - if necessary?Monday, April 30, 2007 2:04 PM -
User-424104626 posted
Ya...Below is my connection string:
Dim connectionString = "Data Source=user-1221;Initial Catalog=surveyAspx;Integrated Security=True"
Dim sqlConn As SqlConnection = New SqlConnection(connectionString)
Dim sql As String = "SELECT * FROM project"
sqlConn.Open()Dim da As SqlDataAdapter = New SqlDataAdapter(sql, sqlConn)
Dim ds As DataSet = New DataSet()' Fill the DataSet
da.Fill(ds)
sqlConn.Close()But when i use visual studio debug button to run the application, it didn't show connection problem & i can connect to db and run the whole application.
Thanks.
Tuesday, May 1, 2007 1:49 AM -
User-424104626 posted
Below is my connection string & code:
Dim connectionString = "Data Source=user-1221;Initial Catalog=surveyAspx;Integrated Security=True"
Dim sqlConn As SqlConnection = New SqlConnection(connectionString)
Dim sql As String = "SELECT * FROM project"
sqlConn.Open()Dim da As SqlDataAdapter = New SqlDataAdapter(sql, sqlConn)
Dim ds As DataSet = New DataSet()' Fill the DataSet
da.Fill(ds)
sqlConn.Close()I already put the folder of application in this path "C:\Inetpub\wwwroot" & add it to IIS web application.
When i try to access it manually with this path http://localhost/mobilesurvey/default.aspx, message as previous post shown.
But the same message didn't pop up when i using visual studio 2005 debug button to run the application.
When i using the debug function in vs 2005, i can connect to db & access the whole application without problem.
Tuesday, May 1, 2007 2:00 AM -
User-424104626 posted
I'm darrent.
Sorry for the duplicate post. But the 1st time when i post, page shown loss conection.
thanks
Tuesday, May 1, 2007 2:08 AM -
User1634317999 posted
It seems that the ASPNET account has no permission to access the SQL Server.
This Knowledge Base article might help you.
If you debug the application with Visual Studio are you using IIS or the built in Development Server? The Dedevelopment Server might run in another security context as IIS which has sufficient permissions to access the database server.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, May 1, 2007 3:43 AM -
User-424104626 posted
Thanks for your help.
i have rectify the problem.
connectionString = "Data Source= ;Initial Catalog= ;Integrated Security=True"
I replace the connection string with user/password connection string.
connectionString = "Data Source= ;Initial Catalog= ;User ID= ;password= "
Now already can work
Thanks a lot.
Tuesday, May 1, 2007 12:54 PM