我想学习如何使用SQL数据适配器......我已经编写了以下检查它是如何工作的?
问题是我想单独找回我的数据库表“萨”的3列(DEPTNO,DEPTID,DEPTNAME)的值,并在三个独立的文本框中显示出来...
通过下面提及的代码我能够检索数据库表的整个元组的共同价值
我应该怎么办,以达到上述结果???
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection connect = new SqlConnection(ConfigurationManager.ConnectionStrings["TestConnectionString"].ConnectionString);
SqlCommand cmd = new SqlCommand("Select DeptNo,DeptId,DeptName from Sana where DeptName='" + TextBox1.Text + "'", connect);
SqlDataAdapter myAdapter = new SqlDataAdapter(cmd);
DataSet MyDataSet = new DataSet();
myAdapter.Fill(MyDataSet, "Departments");
object[] rowVals = new object[3];
foreach (DataTable myTable in MyDataSet.Tables)
{
foreach (DataRow myRow in myTable.Rows)
{
foreach (DataColumn myColumn in myTable.Columns)
{
Response.Write(myRow[myColumn] + "\t");
}
}
}
}
}