Does your SqlDataAdapter have the required SqlCommands it needs (e.g.,
select, insert, update, delete)?
if yes then you can update using code below:
StringBuilder sb = new StringBuilder("");
sb.Append("UPDATE Categories SET ");
sb.Append("CategoryName=@sCategoryName WHERE CategoryID=@nCategoryID");
SqlConnection conn = this.getConnectionString();
SqlCommand cmd = new SqlCommand(sb.ToString(), conn);
SqlParameter p1 = new SqlParameter("@sCategoryName", SqlDbType.VarChar, 30);
p1.Direction = ParameterDirection.Input;
p1.Value = ((TextBox)(e.Item.Cells[1].Controls[0])).Text;
cmd.Parameters.Add(p1);
SqlParameter p2 = new SqlParameter("@nCategoryID", SqlDbType.Int);
p2.Direction = ParameterDirection.Input;
p2.Value = C1WebGrid1.DataKeys[e.Item.ItemIndex];
cmd.Parameters.Add(p2);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
Regards,
Manish
www.ComponentOne.com
> When using the SqlCommand object, records can be inserted/updated/
> deleted in the underlying data source (i.e. the SQL Server database
[quoted text clipped - 17 lines]
> necessary changes in the DataSet for the data source to reflect the
> changes?