Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8275855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:12:14+00:00 2026-06-08T08:12:14+00:00

I have a website that connects to SQLServer Express database files for Membership and

  • 0

I have a website that connects to SQLServer Express database files for Membership and data storage.So I have two .mdf files. Here are the connection strings:

public static string ASPNETDB = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.mdf;Integrated Security=True;User Instance=True;User ID=;Password=; ";
public static string Dok = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\dok.mdf;Integrated Security=True;User Instance=True;User ID=;Password=; ";

Now after deleting and reinstalling the website I’ve been getting numerous errors in the part where a connection is established.Here are the errors:

Unable to open the physical file "C:\Inetpub\wwwroot\BSHHD\App_Data\aspnetdb_log.ldf". 
Operating system error 5: "5(failed to retrieve text for this error. Reason: 1815)".
Cannot open user default database. Login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
File activation failure. The physical file name "C:\Inetpub\wwwroot\BSHHD\App_Data  
\aspnetdb_log.ldf" may be incorrect.
The log cannot be rebuilt because there were open transactions/users when the database 
was shutdown, no checkpoint occurred to the database, or the database was read-only.   
This error could occur if the transaction log file was manually deleted or lost due to 
a hardware or environment failure.

It’s very strange because I did not make any changes to the website. I just deleted it from IIS and reinstalled it. I was suggested to set username and password and remove Integrated Security. But I do not know how to set username/password for a datafile.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:12:16+00:00Added an answer on June 8, 2026 at 8:12 am

    Add the database ASPNETDB.mdf to the SQL Express with SQL Management studio
    You can download it from Microsoft web platform installer.

    Open SQL Management studio
    Right click on Databases > Attach > Add the mdf and log file (Preferable you put them somewhere else then the site directory.

    In MSSQL you can set the username and password easily, Open SQL Management studio.

    Login to the Management studio:
    Expand Security > Logins > Write Click on Logins “New Login”

    Login Name: For example logmein
    Make it SQL Server Authentication
    Set the Passwords
    Remove the Enforce

    On the left side you will have the User Mapping
    Select the Database you want to connect to and give the write permissions, for example if this user can write to the database you will want to make it datawriter or db_owner which is higher permission:

    The database built-in roles are:

    public – the default set of authorizations

    db_owner – allowed to perform any operation of a specified database

    db_oddladmin – allowed to create or modify the new objects of the database (so-called DDL
    operations); you should take notice of the fact that the user doesn’t have to have

    db_owner authorizations to do that

    db_datareader – allowed to read any table

    db_datawriter – allowed to write any table

    db_denydatareader – banned to read tables (an overt authorization takeaway)

    dDb_denydatawriter – banned to write tables

    After you add the database to the SQL:
    You can add in the web.config

    <add name="ASPNETDB" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=ASPNETDB.mdf;User ID=yourusername;Password=yourpassword" providerName="System.Data.SqlClient" />
    <add name="Dok " connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=dok.mdf;User ID=yourusername;Password=yourpassword" providerName="System.Data.SqlClient" />
    

    or if you prefer to have it in the code like you have it above also it can work.

    Regards,
    Gabriel

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a website that is mirrored cross two sub-domains. So I have separate
I have a WCF Library Project that connects to SQL server and the connection
I have an ASP.NET MVC website that connects to a DB via a Web
At the moment I have a website that is connecting to the database the
I have a website that occacionally fails to connect to the database. It starts
I have a WebSite that just don't connect to database. Both are on my
So basically I have website that has names of cities that can be checked
I have a website that is mainly based on JavaScript. It uses a REST
I have a website that logs in using an STS, then gets a delegated
I have a website that in a few months is going to have traffic

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.