Thursday, March 22, 2012

Default ASPNETDB database

Hi

I want to set up my web app to use a web parts personalization, I notice that a default database named aspnetdb is made, I also made one in my sql server using the aspnet_regsql.exe to make it. Now what I need to find out is how to make my app point to the database in the sql server instead of making that default one.

Thanks

You need to modify your connectionstring in the web.config to point to the instance of the DB you wish to connect to.

Marco

Please mark as answered if this helps!

|||

Hi

thanks for the response, how exactly should I use the connection string and where in the file?

thanks

|||

Hello - are you using VWD? Your web.config file will be stored where all your .aspx files are stored. Open the file and make the below changes (in bold)

<connectionStrings>

<addname="DatabaseNameHere"connectionString="Data Source=ComputerNameHere\SQLInstanceNameHere;Initial Catalog=DatabaseNameHere;Integrated Security=True"providerName="System.Data.SqlClient"/>

</connectionStrings>

Marco

|||

Hi, thanks for the string, the connection works but the app still uses that local aspnetbd as the default database, any ideas as to why.

thanks

|||

Hello - try adding a customized membership provider in your web.config, which if implemented as below is just a copy of the default provider but with a different name, Then point the customized membership provider to your connection string. Read this article which fully explains what your are trying to do -http://aspnet.4guysfromrolla.com/articles/120705-1.aspx

<membershipdefaultProvider="CustomizedMembershipProvider">

<providers>

<addname="CustomizedMembershipProvider"type="System.Web.Security.SqlMembershipProvider"connectionStringName="XXXXXXXX"applicationName="XXXXXXXXXX"/>

</providers>

</membership>

|||

Thanks that put me in the right path now im getting a error on the connection string

ERROR :The specified connectionStringName, 'xxxx', was not registered.

Any ideas,

Thanks

|||

Hello - have you replaced the 'xxxx' with the name of your connection string? the name of your connection string is in your web.config

<connectionStrings>

<addname="XXXXX" - this is where the name of your connection string will be.

Marco

|||

Hi, thanks for all your help again, that set me on the right path and I found the solution.

What I found out is that the machine.config file was looking for a connection named LocalSqlServer so in order to override that I had to clear that connection, I was using the <remove> element to remove the LocalSqlServer but didn't seem to work, so I just used the <clear/>, also I named the new connection LocalSqlServer because without it it was giving me a "connectionstring not register" error, so as soon as I named it LocalSqlServer it went through. I'm not sure if it can go in with a different name as every time I tried to name it differently it gave me errors, it was looking for LocalSqlServer regardless. I also had to give the Aspnet user access to that database.

Here is a sample of what I used

<connectionStrings
<clear/>
<add name="LocalSqlServer" connectionString="Data Source=path/;database=aspnetdb;Integrated Security=True" providerName="System.Data.SqlClient" /
</connectionStrings
<system.web
<roleManager enabled="true" />
<compilation debug="true" strict="false" explicit="true"/
<authentication mode="Forms" /
<webParts>
<personalization defaultProvider="AspNetSqlPersonalizationProvider">
<providers
<clear/>
<add connectionStringName="LocalSqlServer"
name="AspNetSqlPersonalizationProvider" type="System.Web.UI.WebControls.WebParts.SqlPersonalizationProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" applicationName="/appname" /
</providers>
</personalization>
</webParts
</system.web
</configuration>

Maybe this might help someone else.

Thanks agian for your help

No comments:

Post a Comment