我已经搜索了网络并搜索了网络,但并没有完全找到我可能遇到的问题。我目前在获取 SqlDataAdapter 来填充 DataSet 时遇到问题。我正在运行 Visual Studio 2008,并且正在将查询发送到 SqlServer 2008 的本地实例。如果我运行查询 SqlServer,它会返回结果。代码如下:
string theQuery = "select Password from Employees where employee_ID = '@EmplID'";
SqlDataAdapter theDataAdapter = new SqlDataAdapter();
theDataAdapter.SelectCommand = new SqlCommand(theQuery, conn);
theDataAdapter.SelectCommand.Parameters.Add("@EmplID", SqlDbType.VarChar).Value = "EmployeeName";
theDataAdapter.Fill(theSet);
读取数据集的代码:
foreach (DataRow theRow in theSet.Tables[0].Rows)
{
//process row info
}
如果我可以提供更多信息,请告诉我。