0

i try to create a connection from my app to database. Build is started but is failed. I don't understand why. When i press login nothing happens. Here is my code:

private void button1_Click(object sender, EventArgs e)
    {
        SqlConnection log = new SqlConnection("Data Source=MODIFIEDforStackOverflow;Initial Catalog=logininfo;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False");

        log.Open();

        string newcon=("select username from login where username='"+textBox1.Text+"' and password='"+textBox2.Text+"'");

        SqlDataAdapter adp = new SqlDataAdapter(newcon, log);

        DataSet ds = new DataSet();

        adp.Fill(ds);

        DataTable dt = ds.Tables[0];

        if (dt.Rows.Count >= 1)
        {
            settext = textBox1.Text;

            welcome wc = new welcome();
            wc.Show();

            this.Hide();
        }else
        {
            label3.Text = "Invalid Login!";
        }
    }

Here is my errors:

Severity Code Description Project File Line Suppression State Error Could not copy "obj\Debug\YourTips_App.exe" to "bin\Debug\YourTips_App.exe". Exceeded retry count of 10. Failed. YourTips_App
Error Unable to copy file "obj\Debug\YourTips_App.exe" to "bin\Debug\YourTips_App.exe". The process cannot access the file 'bin\Debug\YourTips_App.exe' because it is being used by another process. YourTips_App

Thank you!

3
  • Build is failed?You mean any compilation error? You should close the connection after your work in DB,I mean the log.close(); before exiting the method. or enclose this db operations inside using statements.Something like similar to this stackoverflow.com/questions/23185990/… Commented Sep 22, 2017 at 7:53
  • Thnak you for your link but not works in my case. This is my errors:Severity Code Description Project File Line Suppression State Error Could not copy "obj\Debug\YourTips_App.exe" to "bin\Debug\YourTips_App.exe". Exceeded retry count of 10. Failed. YourTips_App Error Unable to copy file "obj\Debug\YourTips_App.exe" to "bin\Debug\YourTips_App.exe". The process cannot access the file 'bin\Debug\YourTips_App.exe' because it is being used by another process. YourTips_App Commented Sep 22, 2017 at 8:01
  • 1)Can you please close the visual studio and open again 2)Rebuild the solution and run again,if it's not tried Commented Sep 22, 2017 at 8:51

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.