Login Control Without SQLEXPRESS
Yesterday not me but my colleague faced one strange problem using Login Control in ASP.NET [I hope you know Login Control…if don’t than this is not for you and going to know than you may face this problem so don’t click on another link go ahead….]. He asked me to help so I dig in it and thanks god I got the solution…you will say that this bloody guy is writing on and on about his friend and solution…BUT WHAT IS THE PROBLEM????. Ok baba don’t get angry I am going to tell what the problem is:
He uses Login Control and wants to use CreateUserWizard control when he runs an Application form shows correctly and when submits the form it shows the screen like below:
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified)
So if you have the same problem than party!!!! Because I have its solution…hey stop where are you going for party???? Wait first try my solution and then go for it…and if possible send me an invitation..So here’s the solution for it and reason for it.
ROOT CAUSE OF THIS PROBLEM:
It goes to find SQLEXPRESS edition. Means when you install ASP.NET with sqlexpress it will configure it in Machine.config file so it will work but when you need to use other version of SQLSERVER than you need to tell ASP.NET that Hey Mr.ASP.NET I want to use Mr.SQLSERVER so please don’t try to use your friend SQLE XPRESS….want more read this from Bible of .NET(MSDN)
When you install ASP.NET, the machine configuration file and the root Web.config file for your server include configuration elements that specify SQL Server providers for each of the ASP.NET features that rely on a provider. These providers are configured, by default, to connect to a local instance of SQL Server Express. If you plan to use only SQL Server Express with the default location specified in the connectionStrings section of the machine configuration file, then you do not need to perform any manual setup of the database. If you need to configure a database using a standard version of SQL Server running on the same server, or if you need to configure a remote SQL Server computer, then you will need to use this tool.
You will say that he is getting us bored by theory I want solution…no worries here’s the solution..Enjoy It!
Step 1: Open .NET SDK Command Prompt.
Step 2: and Type aspnet_regsql.exe -E -S localhost -A mr Where –S <Instance Name> and by default it configures aspnetdb database for Installing database. If you want your database than –d <database> That’s it
Step 3: Now Add the Following Section in <connectionStrings> section of web.config file [Relace <SERVERNAME> with your server name e.g localhost].
<remove name=“LocalSqlServer“ /> <add name=“LocalSqlServer“ connectionString=“Data Source=<SERVERNAME>;Initial Catalog=aspnetdb;Integrated Security=True“ providerName=“System.Data.SqlClient“/>
Now run your application….and Party…you are done..
Want to Know More…http://msdn2.microsoft.com/en-us/library/x28wfk74.aspx
“Have a Happy Coding”