我正在尝试在 Windows 窗体文本框中输入一个学生 ID,并且我希望相应的标签将文本从 label1 更改为 name 列中的数据。我真的对代码感到困惑,因此以下内容。
private void button1_Click(object sender, EventArgs e)
{
SqlCeConnection conn = new SqlCeConnection(@"Data Source=|datadirectory|databse.sdf");
conn.Open();
SqlCeCommand cmdSelect = conn.CreateCommand();
cmdSelect.CommandText = "SELECT * FROM StudentDetails WHERE StudentID = studentIDTextBox.Text";
SqlCeDataReader sr = cmdSelect.ExecuteReader();
DataSet sd = new DataSet();
}
/* using (SqlCeDataAdapter dataAdapter = new SqlCeDataAdapter("SELECT * FROM StudentDetails WHERE StudentID = '" + studentIDTextBox.Text.ToString() + "'", conn)
{
// create the DataSet
DataSet ITIADataSet = new DataSet();
// fill the DataSet using our DataAdapter
dataAdapter.Fill();
}
}
*/