我发现只有在将我的工作代码更改为使用数据视图来显示单行数据而不是文本框后,才会出现这个问题。
我有以下内容:
static SqlConnection dbConnection = new SqlConnection
(DBConnection.DBConnection.connectionString);
SqlDataAdapter holdone = new SqlDataAdapter(getCommand, dbConnection);
DataSet holdall = new DataSet();
DataSet updateall = new DataSet();
DataTable invoiceTable = new DataTable();
DataView invoiceView = new DataView();
这是由IT技术所使用的。
public void GetOne(/* connectionString, string invref, string tableref*/)
{
getCommand = "select *redacted* from " + tableref +
"where *redacted* = " + invref;
using (SqlConnection dbConnection = new SqlConnection
(DBConnection.DBConnection.connectionString))
{
dbConnection.Open();
holdone.Fill(holdall);
invoiceTable = holdall.Tables[0];
dbConnection.Close();
}
DataRowView rowView = invoiceView.AddNew();
rowView["*redacted*"] = invoiceTable;
rowView.EndEdit();
}
错误报告指出
holdone.fill(holdall)
这一行存在问题,但我不确定原因,因为我没有将 SQLCommand
作为参数使用,而是使用了 SQLDataAdapter
的参数。我不太清楚自己哪里出错了。
*
。对于任何困惑感到抱歉。 - Wolfish