guys. I wanna to get a specific value for sql server. The sql table is as below now.
ID / PW / Depart
AAA / 1234 / 1
BBB / 2345 / 2
...
LKL / 8765 / 9
For example, When LKL user access to Logon Form, I want to get the Depart code 9.
But it working not. Maybe some problem. But I couldn't find that no more. :(
Here is my code. I will ppriciate any ideas.
Thanks.
private void MForm_Load(object sender, EventArgs e)
{
Logon lf = new Logon();
String tx = lf.IDTBox.Text;
String str = "Server = 102.201.10.17; Database = Dorw; UID = sa; Password = 565p89";
String qur = "SELECT Depart FROM dbo.PW WHERE Name = @tx";
SqlConnection con = new SqlConnection(str);
SqlCommand cmd = new SqlCommand(qur, con);
cmd.Parameters.AddWithValue("@tx", tx);
con.Open();
using(SqlDataReader reader = cmd.ExecuteReader())
switch (reader.ToString())
{
case "0":
break;
case "1":
treeView1.Nodes[1].Nodes[1].Remove();
break;
case "9":
treeView1.Nodes[0].Nodes[0].Remove();
treeView1.Nodes[1].Nodes[0].Remove();
treeView1.Nodes[1].Nodes[1].Remove();
break;
}
con.Close();
}
Aucun commentaire:
Enregistrer un commentaire