0
我做的WinForms。在说我比较datagridview的列值和dB值..比较的DataGridView和数据库字段更新过程
如果DataGridView
列在数据库中存在我想要做的更新过程如果不存在,我想要做Insert过程。
我想这个代码
string resultJewelId = null; string QueryJewelId = null;
private void AddStockTable()
{
try
{
Sqlcon = objDB.DBConnection();
QueryJewelId= "Select JewelId from tblStock";
Sqlcmd = new SqlCommand(QueryJewelId, Sqlcon);
dr = Sqlcmd.ExecuteReader();
if (dr.HasRows)
{
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
while (dr.Read())
{
resultJewelId = dr.GetString(0);
if (resultJewelId == dataGridView1[0, i].Value.ToString())
{
MessageBox.Show("Update process");
}
else
{
MessageBox.Show("Insert Process");
}
}
}
}
}
catch (Exception ex)
{ MessageBox.Show(ex.ToString()); }
}
虽然条件工作正常。但我不知道如何在移动下一行值环..
请支持我。
感谢和问候
ohhh ...我会尝试... – Veera
如果您发现任何其他解决方案,请更新我... – Veera
我在旅行...会告诉早上.. – Veera