was using c# to develop some application and wanted to connect my application(windows) with SQL database.
using sql 2005 express and visual c# express;
but it kept on throughing the following exception while i try to run my app.
so help me out
"An attempt to attach an auto-named database for file C:\Program Files Microsoft SQL Server MSSQL.1MSSQL Data mann.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."

Could you send code you are using?

here u are !

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;
using System.Data.SqlClient;

namespace WindowsFormsApplication1
    public partial class Form1 : Form
        public Form1()

        SqlConnection SqlConn;
        SqlDataAdapter dat;
        DataSet set;

        private void Form1_Load(object sender, EventArgs e)


        private void button1_Click(object sender, EventArgs e)
            string constring = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Program Files Microsoft SQL Server MSSQL.1 MSSQL Data adila.mdf ;Integrated Security=True;Connect Timeout=30;User Instance=True";
            string updatrec = "INSERT INTO one(name,fathers) VALUES   (@name, @fathers)";
            SqlConn = new SqlConnection();
            SqlConn.ConnectionString = constring;

            SqlCommand sqlCmd = new SqlCommand(updatrec, SqlConn);

            sqlCmd.Parameters.AddWithValue("@name", textBox1.Text);
            sqlCmd.Parameters.AddWithValue("fathers", textBox2.Text);

            catch (System.Exception Exec)



Edited 3 Years Ago by mike_2000_17: Fixed formatting

This article has been dead for over six months. Start a new discussion instead.