我真的很想在这段代码上得到帮助,试图用 C# 连接 SQL 来制作一个 Windows 表单来填写密码和用户名,我 dt.Fill(); 给了一个错误,non-innovocable member... 我想知道我应该如何处理代码?
namespace Homeworkc
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button3_Click(object sender, EventArgs e)
{
this.Close();
Application.Exit();
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=C:\Users\courageboy\AppData\Local\Temporary Projects\Homeworkc\Data.sdf");
SqlDataAdapter sda = new SqlDataAdapter("Select Count(*)From Login where username='" + textBox1.Text + "'and password='" + textBox2.Text + "'", con);
DataTable dt = new DataTable();
dt.Fill();
if (dt.Rows[0][0].ToString() == "1")
{
this.Hide();
Displayform df = new Displayform();
df.Show();
}
else
{
MessageBox.Show("please you have enter a wrong Username or Password");
}
}
}
}