I'm creating a login window in c# with SQL server following this guys tutorial https://www.youtube.com/watch?v=NX8-LhgFnUU
我正在使用SQL服务器在c#中创建一个登录窗口,按照这个人的教程https://www.youtube.com/watch?v=NX8-LhgFnUU
I did everything like he did but I get an error in my code when I debug the app and type username and password and click login. It brings me to code which is this code / screenshots:
我做了一切,就像他做的那样,但是当我调试应用程序并输入用户名和密码并点击登录时,我的代码出错了。它带给我代码,这是代码/截图:
Code:
private void button1_Click(object sender, EventArgs e)
{
SqlConnection sqlcon = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=E:\eAlati - 1366x768\FastFoodDemo\DB\logindb.mdf;Integrated Security=True;Connect Timeout=30");
string query = "Select * from Table Where username = '" + txtUsername.Text.Trim() + "'and password = '" + txtPassword.Text.Trim() + "'";
SqlDataAdapter sda = new SqlDataAdapter(query, sqlcon);
DataTable dtbl = new DataTable();
sda.Fill(dtbl);
if(dtbl.Rows.Count == 1)
{
ucitavanje objUcitavanje = new ucitavanje();
this.Hide();
objUcitavanje.Show();
}
else
{
MessageBox.Show("Vaše korisničko ime ili lozinka nisu točni! Pokušajte ponovno");
}
}
Thanks for understanding :)
感谢您的理解 :)
1 个解决方案
#1
1
For the fix I put Table in square brackets like this [Table] this solved things :D
为了解决这个问题,我将Table放在方括号中,就像这个[表]一样,这解决了问题:D
#1
1
For the fix I put Table in square brackets like this [Table] this solved things :D
为了解决这个问题,我将Table放在方括号中,就像这个[表]一样,这解决了问题:D