我正在尝试根据数据集中的查询存储未保存的记录,以便在网格视图中向用户显示它没有运气,如何使用以下代码将它们保存在数据集中?
for (int i = 1; i < recs.Tables[0].Rows.Count; i++)
{
try
{
validateQuery = "SELECT .... "
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(validateQuery, conn);
DataSet ds = new DataSet();
da.Fill(ds, "candRecs");
DataTable dt = new DataTable();
dt = ds.Tables[0];
int RowsCount = dt.Rows.Count;
if (RowsCount == 0)
{
//conn.Open();
cmd = new SqlCommand(query, conn);
cmd.Parameters.AddWithValue("@CAND_CARD_NO", recs.Tables[0].Rows[i][0].ToString());
....
cmd.ExecuteNonQuery();
}
else
{
x++;
//What I should to write here to store the records in Dataset ??
}
...