Database connection problems

B

BobLaughland

Hi There,

I am writing an ASP .NET 2.0 web site.

I have a connection string in my web.config file similar to this for
connecting to my database,

SERVER=125.165.165.116,1092; DATABASE=blah***; UID=Blah***;
PWD=blah*****

That is connecting to a proper database server, and I can indeed
connect (using SQL server management studio).

Anyway my web site has a login page using the .NET 2.0 login control.
When I try to login it tells me it cannot connect to the database, and
that it was looking for an 'App_Data' folder with the database, and
that it couldn't create it.

Even though I have changed the connection string it is still looking
for a SQLSERVER express database file in the default folder (this was
how my web site was set up before until I put it online).

Please help.

Thanks,

Peter.
 
W

Ward Bekker

Hi Peter,

I myself struggled with the same issue. Maybe I looked in the wrong
place but something simple like switching to sql server is impossible to
find in the MSDN docs. One solution i found was using this piece in my
web.config. Don't forget to have a connectionstring with the key
MyLocalSQLServer.


<roleManager enabled="true" defaultProvider="MySqlRoleProvider">
<providers>
<clear/>
<add name="MySqlRoleProvider"
connectionStringName="MyLocalSQLServer" applicationName="MyAppName"
type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</roleManager>
<profile enabled="true" defaultProvider="MySqlProfileProvider">
<providers>
<clear/>
<add name="MySqlProfileProvider"
connectionStringName="MyLocalSQLServer" applicationName="MyAppName"
type="System.Web.Profile.SqlProfileProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</profile>
<authentication mode="Forms">
<forms name="SqlAuthCookie"/>
</authentication>
<membership defaultProvider="MySqlMembershipProvider">
<providers>
<clear/>
<add name="MySqlMembershipProvider"
connectionStringName="MyLocalSQLServer" applicationName="MyAppName"
type="System.Web.Security.SqlMembershipProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</membership>



--
Ward Bekker
"Asp.Net Discussions for the Professional Developer"
http://www.dotnettaxi.com

"Free .Net 2.0 C# to/from VB.Net Code Converter"
http://www.dotnettaxi.com/Tools/Converter.aspx
 
S

sloan

When you draw a login control onto a form, you are saying "I want to use a
Membership Provider".

This has NOTHING to do with your database.

The default Membership Provider wants to use a locally installed express
database.

...

You can either remove the login control

OR

You can implement the default Membership Provider, which will somewhere put
a express database in that folder.

OR

You can write a custom Membership Provider to talk to your database.
(not trivial)
...
 
B

BobLaughland

Acually I hunted, and hunted. You will be pleasently surprised with the
solution.

There seems to be a connection string called 'LocalSqlServer' set up by
default behind the scenes. If you 'remove' that string first then you
can override it with your own settings.

<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data
Source=****;Initial Catalog=****;Persist Security Info=****;User
ID=****;Password=****" providerName="System.Data.SqlClient"/>
</connectionStrings>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,135
Latest member
VeronaShap
Top