0

An attempt to attach an auto-named database failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

I used fwad randomly. Is that supposed to mean something? It says that is the error. Please help, I don't understand c# jargon well so in depth answers would be a major +1

private void label2_Click(object sender, EventArgs e)
{

}

private void loginpage_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{

    SqlConnection sqlcon = new SqlConnection(@"clearedonpurpose");
    string query = "Select * from Table Where username = '" + textBox1.Text.Trim() + "' and password = '" + textBox2.Text.Trim() + "'";
    SqlDataAdapter fwad = new SqlDataAdapter(query, sqlcon);
    DataTable Table = new DataTable();
    fwad.Fill(Table);
    if (Table.Rows.Count == 1)
    {
        Form1 objFrmMain = new Form1();
        this.Hide();
        objFrmMain.Show();
    }
    else
    {
        MessageBox.Show("Wrong!");
    }
}

private void button2_Click(object sender, EventArgs e)
{
    this.Close();
}

private void textBox1_TextChanged(object sender, EventArgs e)
{

}
CodeCaster
  • 147,647
  • 23
  • 218
  • 272
Jason Kats
  • 61
  • 1
  • 1
  • 5
  • Possible duplicate of [An attempt to attach an auto-named database for file ....database1.mdf failed](http://stackoverflow.com/questions/12566036/an-attempt-to-attach-an-auto-named-database-for-file-database1-mdf-failed) – Dinny Dec 26 '16 at 12:09
  • post you DB connectionstring – Alrehamy Dec 26 '16 at 12:13
  • Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C: \Users\...\Downloads\...\hax.mdf;Integrated Security=True;Connect Timeout=30" – Jason Kats Dec 26 '16 at 12:17

0 Answers0