我在我的數據庫中有一列「Klantnummer」和
我希望將該值作爲我的標籤文本。
我該怎麼做?如何使用數據庫中的值設置我的標籤文本?
protected string conS = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\Databees.mdf;Integrated Security=True;User Instance=True";
protected SqlConnection con;
protected void Page_Load(object sender, EventArgs e)
{
con = new SqlConnection(conS);
try
{
con.Open();
string q = "SELECT * FROM tblKLanten;";
SqlCommand query = new SqlCommand(q, con);
SqlDataReader dr = query.ExecuteReader();
Label1.Text = ; //I want here the value of klantnummer
con.Close();
}
catch (Exception ex)
{
Label2.Text = "Error";
}
}