By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,786 Members | 1,143 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,786 IT Pros & Developers. It's quick & easy.

Database connection problems

P: n/a
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.

Mar 1 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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
Mar 1 '06 #2

P: n/a

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)
...


"BobLaughland" <pe*************@gmail.com> wrote in message
news:11*********************@j33g2000cwa.googlegro ups.com...
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.

Mar 1 '06 #3

P: n/a
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>

Mar 2 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.