【发布时间】:2014-01-08 14:21:50
【问题描述】:
我想将在 datagridview 中输入的值存储到 SQL Server 中,但如果第二行为空,则其显示对象引用未设置为对象实例
private void btnSave_Click(object sender, EventArgs e)
{
int i = 0;
foreach (DataGridViewRow row in dataGridView1.Rows)
//{
{
string keyword = row.Cells[0].Value.ToString();
string name = row.Cells[1].Value.ToString();
string comm = row.Cells[2].Value.ToString();
string retur = row.Cells[3].Value.ToString();
string message = row.Cells[4].Value.ToString();
i = pbl.fsave(keyword, name, comm, retur, message);
}
//string insert_sql = "INSERT INTO TblProtocolDetails(KeyWord,Command,Return)VALUES('" + keyword + "','" + comm + "','" + retur + "')";
//}
}
【问题讨论】:
-
有什么问题??