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 8853363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:38:03+00:00 2026-06-14T13:38:03+00:00

I am actually developing a Windows Forms Application with Visual C# Express 2010 which

  • 0

I am actually developing a Windows Forms Application with Visual C# Express 2010 which would use (read/write) data from a SQL Server 2008 Express DB

I have created my DB with SQL Server Management Studio (2008 Express),
I understand the instance is named ATLELAG786576\SQLEXPRESS
My DB is called ‘TEST’

Looking at my DB ‘TEST’ Properties in SQL Server Management Studio (2008 Express):
Under Files, I am (ATLE\bneveux) the owner of the DB

Looking under Security, Logins, Mylogin (ATLE\bneveux)

  • My default DB is ‘TEST’
  • Server roles are ‘public’ + ‘sysadmin’
  • User Mapping DB ‘TEST’ User ‘dbo’ Default Schema ‘dbo’

In my C# application

app.config:

<?xml version="1.0" encoding="utf-8" ?> <configuration>
    <configSections>
    </configSections>
    <connectionStrings>
        <add name="connectionStringTestDb"
            connectionString="Data Source=ATLELAG786576\SQLEXPRESS;Initial Catalog=D:\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\TEST.mdf;Integrated Security=True;Connect Timeout=30;User Instance=False"
            providerName="System.Data.SqlClient" />
    </connectionStrings> </configuration>

dbConnection.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace SQLServerConnectionDemo
{
    class dbConnection
    {
        public static SqlConnection newCon;
        public static string connectionStringTestDb = ConfigurationManager.ConnectionStrings["connectionStringTestDb"].ConnectionString;

        public static SqlConnection GetConnection()
        {
            newCon = new SqlConnection(connectionStringTestDb);
            return newCon;
        }
    }
}

dbAccess.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace SQLServerConnectionDemo
{
    class dbAccess
    {
        SqlConnection conn;
        public dbAccess()
        {
            conn = dbConnection.GetConnection();
        }

        //Method insert new in tblEmployees
        public void addEmployee(string Id, string Name, string Email)
        {
            if (conn.State.ToString() == "Closed")
            {
                conn.Open();
            }
            SqlCommand newCmd = conn.CreateCommand();
            newCmd.Connection = conn;
            newCmd.CommandType = CommandType.Text;
            newCmd.CommandText = "INSERT INTO tblEmployees VALUES ('"+ Id +"','"+ Name +"','"+ Email +"')";
            newCmd.ExecuteNonQuery();
        }

    }
}

in a form formEmployeeAdd.cs:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SQLServerConnectionDemo
{
    public partial class formEmployeeAdd : Form
    {

        dbAccess access = new dbAccess();

        public formEmployeeAdd()
        {
            InitializeComponent();
        }

        private void btnInsert_Click(object sender, EventArgs e)
        {
            access.addEmployee(txtId.Text, txtName.Text, txtEmail.Text);
            MessageBox.Show("Data successfully added");
        }
    }
}

And here the error message I always get when trying to run this process:

System.Data.SqlClient.SqlException (0x80131904): Cannot open database “D:\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\TEST.mdf” requested by the login. The login failed.
Login failed for user ‘ATLE\bneveux’.

Note that I have never really been able to add my Data Source in Visual C# 2010 Express so I could manage the DB from VS, I always get the following error message:

Unable to open the physical file “D:\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\TEST.mdf”. Operating system error 32: “32(Le processus ne peut pas accéder au fichier car ce fichier est utilisé par un autre processus.)”.
An attempt to attach an auto-named database for file D:\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\TEST.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

  • 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-14T13:38:05+00:00Added an answer on June 14, 2026 at 1:38 pm

    Try replacing

    Initial Catalog=D:\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\TEST.mdf
    

    with simply

    Initial Catalog=TEST
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an application for Windows Phone 7. I am trying to use
I'm developing a Windows Forms application in VS2008. I want to display a unknown,
VB Windows form Application.. I am developing an application of which part of the
I've been developing a small in house application in C++ to access data from
I am developing on a Windows Server 2008 box, with Visual Studio 2010 Ultimate,
I'm actually developing an application using Google Drive SDK. I don't want to create
Actually I am developing one application in that when application run first time it
I'm developing a JSF web application, with the current 2.1.7 JSF version . Actually,
I am actually developing and application that has around 15 modules, all of them
I'm developing C++ apps for Linux, but my workstation is Windows 7. I've read

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.