Solved

Web.config file for database connection.

Posted on 2007-11-18
20
582 Views
Last Modified: 2012-08-14
I have the following:

<connectionStrings>
            <add name="aspnet_staterKits_TimeTracker" connectionString="Data Source=.\SQLExpress;Integrated Security=True;AttachDBFilename=|DataDirectory|TimeTracker.mdf;User Instance=true" />
            <remove name="LocalSqlServer"/>
            <add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;AttachDBFilename=|DataDirectory|TimeTracker.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.
0
Comment
Question by:mathieu_cupryk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 8
  • 2
20 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20307766
you only have to change the dat Source parameter into the instance of the sql server 2005.
0
 

Author Comment

by:mathieu_cupryk
ID: 20307814
The instance is Quincy which is the server name
what else do I do?
0
 
LVL 16

Expert Comment

by:McExp
ID: 20307827
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_TimeTracker" connectionString="Data Source=Quincy;Initial Catalog=TimeTracker;Integrated Security=True;" providerName="System.Data.SqlClient"/>
  </connectionStrings>
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20307833
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.
0
 
LVL 16

Accepted Solution

by:
McExp earned 500 total points
ID: 20307841
An Sql Server connectionstring requires two bits of information the server name (DataSource) and Database name (Initial Catalog). My first post gives you the format for the connectionString this second should give you the info you need to configure to your requirements.

Once again, assuming all of the info is in one database (TimeTracker) the following should work

  <connectionStrings>
    <add name="aspnet_staterKits_TimeTracker" connectionString="Data Source=Quincy;Initial Catalog=TimeTracker;Integrated Security=True;" providerName="System.Data.SqlClient"/>
    <remove name="LocalSqlServer"/>
    <add name="LocalSqlServer" connectionString="Data Source=Quincy;Initial Catalog=TimeTracker;Integrated Security=True;" providerName="System.Data.SqlClient"/>
  </connectionStrings>
0
 

Author Comment

by:mathieu_cupryk
ID: 20307858
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.SqlException: Cannot open database "TimeTracker" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
0
 

Author Comment

by:mathieu_cupryk
ID: 20307863
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.SqlException: Cannot open database "TimeTracker" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
0
 
LVL 16

Expert Comment

by:McExp
ID: 20307885
Are you using anonymous auth on your site?
0
 

Author Comment

by:mathieu_cupryk
ID: 20307889
Well is it ok if I went into properties of sql server and change quincy\administrator to
NT AUTHORITY\NETWORK SERVICE under Files --> Owner
0
 
LVL 16

Expert Comment

by:McExp
ID: 20307891
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!
0
 
LVL 16

Expert Comment

by:McExp
ID: 20307899
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!
0
 

Author Comment

by:mathieu_cupryk
ID: 20307907
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.Provider.ProviderException: 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.  
0
 
LVL 16

Expert Comment

by:McExp
ID: 20307913
So I'm assuming your using a Roles Provider?

What is the database that contains your Membership database?
0
 

Author Comment

by:mathieu_cupryk
ID: 20307944
Sql server 2005.
and the instance is quincy
and the name of the db is TimeTracker.
0
 
LVL 16

Expert Comment

by:McExp
ID: 20307957
So what is your Roles provider configuration set too, please provide full web.config
0
 

Author Comment

by:mathieu_cupryk
ID: 20307973
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_TimeTracker" connectionString="Data Source=Quincy;Initial Catalog=TimeTracker;Integrated Security=True;" providerName="System.Data.SqlClient"/>
    <remove name="LocalSqlServer"/>
    <add name="LocalSqlServer" connectionString="Data Source=Quincy;Initial Catalog=TimeTracker;Integrated Security=True;" providerName="System.Data.SqlClient"/>
  </connectionStrings>



  <system.web>
            <siteMap defaultProvider="AspNetXmlSiteMapProvider" enabled="true">
                  <providers>
                        <clear />
                        <add name="AspNetXmlSiteMapProvider"
                              type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
                              siteMapFile="web.sitemap"
                              securityTrimmingEnabled="true"  />
                  </providers>
            </siteMap>
            <authentication mode="Forms">
                  <forms loginUrl="~/TimeTracker/login.aspx"/>
            </authentication>
            <compilation debug="false" />
            <customErrors mode="RemoteOnly"/>
            <machineKey decryptionKey="AutoGenerate,IsolateApps"/>
            <roleManager enabled="true" />
      </system.web>
</configuration>
0
 
LVL 16

Expert Comment

by:McExp
ID: 20307992
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: -





		<roleManager enabled="true" cacheRolesInCookie="true" defaultProvider="AccessRoleProvider">
			<providers>
				<add connectionStringName="ASPNetDB" applicationName="RAdmin" name="AccessRoleProvider" type="Samples.AccessProviders.AccessRoleProvider"/>
			</providers>
		</roleManager>

Open in new window

0
 

Author Comment

by:mathieu_cupryk
ID: 20310061
I will put this in my config in comments for future reference. I learned alot. Thanks man.
A+
0
 

Author Comment

by:mathieu_cupryk
ID: 20310064
This is the bulk of the answer.
0
 

Author Closing Comment

by:mathieu_cupryk
ID: 31409803
This is great job.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Easy filter aspnet 2 36
disable data migrations in visual studio 2017 4 52
pressing download button in c# 7 36
Data organization issue 7 40
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question