mathieu_cupryk
asked on
Web.config file for database connection.
I have the following:
<connectionStrings>
<add name="aspnet_staterKits_Ti meTracker" connectionString="Data Source=.\SQLExpress;Integr ated Security=True;AttachDBFile name=|Data Directory| TimeTracke r.mdf;User Instance=true" />
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integr ated Security=True;AttachDBFile name=|Data Directory| TimeTracke r.mdf;User Instance=true" />
</connectionStrings>
-------------------------- ---------- ---------- ---------- ---------- ------
I have installed sql server 2005 enterprise and attached TimeTracker.mdf
How can I chage the above to conform to SQL Server 2005.
<connectionStrings>
<add name="aspnet_staterKits_Ti
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integr
</connectionStrings>
--------------------------
I have installed sql server 2005 enterprise and attached TimeTracker.mdf
How can I chage the above to conform to SQL Server 2005.
you only have to change the dat Source parameter into the instance of the sql server 2005.
ASKER
The instance is Quincy which is the server name
what else do I do?
what else do I do?
Assuming that inside of TimeTracker.mdf you have a database called TimeTracker the following should give you what you need.
<connectionStrings>
<add name="aspnet_staterKits_Ti meTracker" connectionString="Data Source=Quincy;Initial Catalog=TimeTracker;Integr ated Security=True;" providerName="System.Data. SqlClient" />
</connectionStrings>
<connectionStrings>
<add name="aspnet_staterKits_Ti
</connectionStrings>
as said, you need to specify the instance name:
Data Source=.\Quincy
what else to do depends on what problem(s) you get after adjusting the connection string.
Data Source=.\Quincy
what else to do depends on what problem(s) you get after adjusting the connection string.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I was just doing what you were writting;
I found a news group however, I got this message.
Cannot open database "TimeTracker" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
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.Data.SqlClient.SqlE xception: Cannot open database "TimeTracker" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
I found a news group however, I got this message.
Cannot open database "TimeTracker" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
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.Data.SqlClient.SqlE
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
ASKER
http://forums.asp.net/t/1181594.aspx
Then I got this:
Cannot open database "TimeTracker" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
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.Data.SqlClient.SqlE xception: Cannot open database "TimeTracker" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
Then I got this:
Cannot open database "TimeTracker" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
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.Data.SqlClient.SqlE
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
Are you using anonymous auth on your site?
ASKER
Well is it ok if I went into properties of sql server and change quincy\administrator to
NT AUTHORITY\NETWORK SERVICE under Files --> Owner
NT AUTHORITY\NETWORK SERVICE under Files --> Owner
Your Sql server will only allow you to connect from an account that has permissions, if you add the 'NT AUTHORITY\NETWORK SERVICE' to the users in Sql Server and give the appropriate permissions to give that user access to the required tables all should be ok!
That is dangerous, that gives the website full permissons as DBO to do whatever to your website.
If you are not internet facing it is not such a big issue, however if not you are leaving yourself very vunrable to hackers!
If you are not internet facing it is not such a big issue, however if not you are leaving yourself very vunrable to hackers!
ASKER
Now when I do a register.aspx page I get this error guys:
The role 'ProjectAdministrator' was not found.
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.Configuration.Provi der.Provid erExceptio n: The role 'ProjectAdministrator' was not found.
Source Error:
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:
1. Add a "Debug=true" directive at the top of the file that generated the error. Example:
<%@ Page Language="C#" Debug="true" %>
or:
2) Add the following section to the configuration file of your application:
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.
Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.
The role 'ProjectAdministrator' was not found.
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.Configuration.Provi
Source Error:
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:
1. Add a "Debug=true" directive at the top of the file that generated the error. Example:
<%@ Page Language="C#" Debug="true" %>
or:
2) Add the following section to the configuration file of your application:
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.
Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.
So I'm assuming your using a Roles Provider?
What is the database that contains your Membership database?
What is the database that contains your Membership database?
ASKER
Sql server 2005.
and the instance is quincy
and the name of the db is TimeTracker.
and the instance is quincy
and the name of the db is TimeTracker.
So what is your Roles provider configuration set too, please provide full web.config
ASKER
ok but I fix it with aspnet_regsql.exe
-------------------------- ---------- --------
Here is my web.config, I like learning new things.
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<connectionStrings>
<add name="aspnet_staterKits_Ti meTracker" connectionString="Data Source=Quincy;Initial Catalog=TimeTracker;Integr ated Security=True;" providerName="System.Data. SqlClient" />
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=Quincy;Initial Catalog=TimeTracker;Integr ated Security=True;" providerName="System.Data. SqlClient" />
</connectionStrings>
<system.web>
<siteMap defaultProvider="AspNetXml SiteMapPro vider" enabled="true">
<providers>
<clear />
<add name="AspNetXmlSiteMapProv ider"
type="System.Web.XmlSiteMa pProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d 50a3a"
siteMapFile="web.sitemap"
securityTrimmingEnabled="t rue" />
</providers>
</siteMap>
<authentication mode="Forms">
<forms loginUrl="~/TimeTracker/lo gin.aspx"/ >
</authentication>
<compilation debug="false" />
<customErrors mode="RemoteOnly"/>
<machineKey decryptionKey="AutoGenerat e,IsolateA pps"/>
<roleManager enabled="true" />
</system.web>
</configuration>
--------------------------
Here is my web.config, I like learning new things.
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<connectionStrings>
<add name="aspnet_staterKits_Ti
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=Quincy;Initial Catalog=TimeTracker;Integr
</connectionStrings>
<system.web>
<siteMap defaultProvider="AspNetXml
<providers>
<clear />
<add name="AspNetXmlSiteMapProv
type="System.Web.XmlSiteMa
siteMapFile="web.sitemap"
securityTrimmingEnabled="t
</providers>
</siteMap>
<authentication mode="Forms">
<forms loginUrl="~/TimeTracker/lo
</authentication>
<compilation debug="false" />
<customErrors mode="RemoteOnly"/>
<machineKey decryptionKey="AutoGenerat
<roleManager enabled="true" />
</system.web>
</configuration>
Congratulations, You say you've fixed it?
I was only going to check that you didn't have any custom provider definitions that would be pointed at the wrong db. you havent as you've left the config defualt. An example of a custom Provider is shown below: -
I was only going to check that you didn't have any custom provider definitions that would be pointed at the wrong db. you havent as you've left the config defualt. An example of a custom Provider is shown below: -
<roleManager enabled="true" cacheRolesInCookie="true" defaultProvider="AccessRoleProvider">
<providers>
<add connectionStringName="ASPNetDB" applicationName="RAdmin" name="AccessRoleProvider" type="Samples.AccessProviders.AccessRoleProvider"/>
</providers>
</roleManager>
ASKER
I will put this in my config in comments for future reference. I learned alot. Thanks man.
A+
A+
ASKER
This is the bulk of the answer.
ASKER
This is great job.