Solved: Asp.net 3.5 and SQL - Log in

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

bretta91

Thread Starter
Joined
May 22, 2010
Messages
32
Hello, I dont have much experience with this. [using asp.net 3.5 in vs 2008 + sql server 2008 on windows 7 (localhost) ]

I want to create a log in authentication and i try to use the ready made log in wizard from asp.net. i saw in a tutorial that it creates the database automatically when u try to log in withou having an existing database. in my case its not creating a database instead just giving a full page error. How can i solve this ? ty

in my case im getting this error>
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

[FONT=Arial, Helvetica, Geneva, SunSans-Regular, sans-serif]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.

SQLExpress database file auto-creation error:

The connection string specifies a local Sql Server Express instance using a database location within the applications App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The following configuration requirements are necessary to successfully check for existence of the application services database and automatically create the application services database:


  1. If the applications App_Data directory does not already exist, the web server account must have read and write access to the applications directory. This is necessary because the web server account will automatically create the App_Data directory if it does not already exist.
  2. If the applications App_Data directory already exists, the web server account only requires read and write access to the applications App_Data directory. This is necessary because the web server account will attempt to verify that the Sql Server Express database already exists within the applications App_Data directory. Revoking read access on the App_Data directory from the web server account will prevent the provider from correctly determining if the Sql Server Express database already exists. This will cause an error when the provider attempts to create a duplicate of an already existing database. Write access is required because the web server accounts credentials are used when creating the new database.
  3. Sql Server Express must be installed on the machine.
  4. The process identity for the web server account must have a local user profile. See the readme document for details on how to create a local user profile for both machine and domain accounts.
[/FONT]
Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:

[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4849015
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject) +4862333
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +90
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +376
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +221
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +189
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +4863459
System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) +29
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +4865788
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +117
System.Data.SqlClient.SqlConnection.Open() +122
System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString) +82

[HttpException (0x80004005): Unable to connect to SQL Server database.]
System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString) +137
System.Web.Management.SqlServices.SetupApplicationServices(String server, String user, String password, Boolean trusted, String connectionString, String database, String dbFileName, SqlFeatures features, Boolean install) +94
System.Web.Management.SqlServices.Install(String database, String dbFileName, String connectionString) +25
System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile(String fullFileName, String dataDir, String connectionString) +395
 
Joined
Oct 30, 2008
Messages
276
I think this is a simple misunderstanding.
While the ASP Administration tools will create the necessary tables on the database if they are not found, it will not create a connection to a database. The problem is indicated by:
"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible."

Establish a connection to a remote or local SQL Server and try again using that login info. If the connection information is correct, check the read/write permissions on the database.

GL,
 

bretta91

Thread Starter
Joined
May 22, 2010
Messages
32
thank you DaBeers, i solved it!

But i have a new problem now. I added the loginstatus on all the pages to show a login button when not logged in and log out button when loged in. Everytime i click a link to change the page (to another page where also ive added loginstatus)

here is the code of loginstatus>
<li><a href="login.aspx">
<asp:LoginStatus ID="LoginStatus1" runat="server"
LoginImageUrl="~/images/login1.JPG" LogoutImageUrl="~/images/logout.JPG" />
<span class="dis_none">Log In</span>
</a></li>





it gives me the following error>

Control 'LoginStatus1' of type 'LoginStatus' must be placed inside a form tag with runat=server.

[FONT=Arial, Helvetica, Geneva, SunSans-Regular, sans-serif] 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.Web.HttpException: Control 'LoginStatus1' of type 'LoginStatus' must be placed inside a form tag with runat=server.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:

[HttpException (0x80004005): Control 'LoginStatus1' of type 'LoginStatus' must be placed inside a form tag with runat=server.]
System.Web.UI.Page.VerifyRenderingInServerForm(Control control) +8691203
System.Web.UI.WebControls.LoginStatus.RenderContents(HtmlTextWriter writer) +38
System.Web.UI.WebControls.LoginStatus.Render(HtmlTextWriter writer) +10
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.Page.Render(HtmlTextWriter writer) +29
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +12[/FONT]
 
Joined
Oct 30, 2008
Messages
276
The code you show isn't what's causing the problem. The error says you need to place your list inside a set of form tags, with the runat=server call in it. Your page should look something like this:
Code:
<HTML>
<HEAD><TITLE></TITLE></HEAD>
<BODY>
<FORM ID = "Form1" runat = "Server">
List goes here
</FORM>
</BODY>
</HTML>
I was actually not aware this was a requirement as I have naturally always placed the control inside a form. I too learned something.
GL,
 

bretta91

Thread Starter
Joined
May 22, 2010
Messages
32
hehehe well, life teaches us something everyday :) thank you it solved the issue. works perfect now ;)

one more question if i may ?

i have a fromt page that will show some pictures. can i control the pictures from a database (SQL)? meaning retreive the picture from the database and when i change the database picture, the site picture will change also. if this can be done can i know how ?
 
Joined
Oct 30, 2008
Messages
276
I played with this a little while back. It is possible, but it's not easy.

You have to take the file apart into it's main components, which consist of the file size, the file name, the file extension, and an array of bits that holds the actual file data.

With all these file components saved to the database, you can than reassemble the file when needed.

If this sounds like a valid approach, let me know and I'll try to hunt down a step-by-step for you.

**Sry, noticed it was SQL Server after posting this. (mine was in Access) It may be easier their than what I went through. I will try to find us something for clearification:...


These are some good examples of the process for SQL Server. Unforunately, it's what I did for Access as well.
C#:
http://www.c-sharpcorner.com/Upload...ges09232005080918AM/AddandRetrieveImages.aspx

VB:
http://forums.techarena.in/software-development/1124120.htm
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top