Hi,
I want to update a record in my dataview. But it is not working. The code is...
string connstr = "Data Source=ARKA-PC;Initial Catalog=rgdb;User Id = sa;password = 12345";
SqlConnection conn = new SqlConnection(connstr);
SqlCommand cmd;
SqlDataAdapter sda = new SqlDataAdapter();
DataSet ds = new DataSet();
DataView dv;
try
{
conn.Open();
cmd = new SqlCommand("select * from reg_table", conn);
sda.SelectCommand = cmd;
sda.Fill(ds, "reg_table");
sda.Dispose();
cmd.Dispose();
conn.Close();
dv = new DataView(ds.Tables[0], "", "country", DataViewRowState.CurrentRows);
int index = dv.Find("'yemen'");
if (index == -1)
{
Response.Write("country not found");
}
else
{
dv[index]["country"] = "germany";
Response.Write("country Updated !");
}
GridView1.DataSource = dv;
GridView1.DataBind();
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
Can anybody help ??
Thanks
Akiii