namespace iss_farmacie_spitali
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SqlDataReader reader = null;
DataTable table = null;
try
{
sqlConnection1.Open();
}
catch(Exception f)
{
Console.WriteLine(e.ToString());
}
sqlCommand1.Parameters.AddWithValue("@user",textBox1.Text);
sqlCommand1.Parameters.AddWithValue("@pass",textBox2.Text);
sqlCommand1.CommandText = "SELECT id,parola FROM ANGAJAT WHERE id='@user' AND parola='@pass'";
reader = sqlCommand1.ExecuteReader();
table.Load(reader);
sqlConnection1.Close();
}
}
}
所以我试图在这里进行我的忠实登录,但我不断收到空引用错误。我需要帮助的是了解如何处理从 sql 获得的数据,以及如何使其可用作字符串等。