hello,
Is there chance to add using insert after update this table?
Then add like a table_report who is update, name, time, ip
So the idea i want if anyone using this button Ondeletesp
Get all info, i know all this but i don’t know where to add because i did try and not working
protected void OnDeletesp(object sender, EventArgs e)
{
GridViewRow row = (sender as Button).NamingContainer as GridViewRow;
string conString = ConfigurationManager.ConnectionStrings["cmConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(conString))
{
using (SqlCommand cmd = new SqlCommand("UPDATE Table_infoname SET CountryId2 = @CountryId2, dateadd2 = @dateadd2, UpdateRating = @UpdateRating WHERE id=@id", con))
{
string id = GridView1.DataKeys[row.RowIndex].Values[0].ToString();
cmd.Parameters.AddWithValue("@CountryId2", "return");
cmd.Parameters.AddWithValue("@dateadd2", SqlDbType.DateTime).Value = DateTime.Now;
cmd.Parameters.AddWithValue("@UpdateRating", "NotRating");
cmd.Parameters.AddWithValue("@id", id);
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
switch (hfSelectedDDL.Value.ToLower())
{
case "country":
break;
case "state":
this.BindGridView2();
break;
case "city":
this.BindGridView();
break;
default:
break;
}
}
using (con = new SqlConnection(constr))
{
int Id = 0;
string constr = ConfigurationManager.ConnectionStrings["cmConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("Insert_UserAAD"))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.CommandType = CommandType.StoredProcedure;
if (!string.IsNullOrEmpty(fName.Text.Trim()))
{
cmd.Parameters.AddWithValue("@name", fName.Text.Trim());
}
if (!string.IsNullOrEmpty(ffileid.Text.Trim()))
{
cmd.Parameters.AddWithValue("@fileid", ffileid.Text.Trim());
}
cmd.Parameters.AddWithValue("@iPAddress", usernamemove);
cmd.Parameters.AddWithValue("@dataaddtime", Convert.ToDateTime(DateTime.Now.ToLongTimeString()));
cmd.Parameters.AddWithValue("@edit", "(update)");
cmd.Connection = con;
con.Open();
Id = Convert.ToInt32(cmd.ExecuteScalar());
con.Close();
}
}
}