TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Daniel Koh
NA
60
15.5k
System.Data.SqlClient.SqlException
Oct 10 2017 12:03 AM
Hi guys i'm learning C# now and am trying to create a login application and one of the lines for sql gave me this error
System.Data.SqlClient.SqlException: 'An attempt to attach an auto-named database for file C: \*****\**********\Documents\Data.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.'
this is the code i was learning:
SqlConnection sqlConnection = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C: \*****\**********\Documents\Data.mdf;Integrated Security=True;Connect Timeout=30;");
SqlDataAdapter sqlDataAdapter = new SqlDataAdapter("Select Count(*) From Login where Username='" + textBox1.Text + "' and Password = '" + textBox2.Text + "'",sqlConnection);
DataTable dataTable = new DataTable();
sqlDataAdapter.Fill(dataTable);
if (dataTable.Rows[0][0].ToString() == "1")
{
this.Hide();
Form2 MainMenu = new Form2();
MainMenu.Show();
}
else
{
MessageBox.Show("Please check your username and password");
}
HELP
Reply
Answers (
2
)
How to get the year wise employee as per the promotion
How to manage patches of database?