hi friends,
this below code frontend and backend to click event insert button-its working,
but,
i want to insert or update the latest records - only backend (sqlserver) via asp.net. or iis
please give the solution for this.
create table emp(_id int primary key identity(1,1),calldate varchar(200),clid varchar(300),userfield varchar(255))
public void fillgrid()
{
OpenConnection(con);
cmd.Connection = con;
SqlDataAdapter da = new SqlDataAdapter("select top 1 calldate fromemp", con);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
Label1.Text = String.Format("{0:yyyy-MM-dd HH:mm:ss.fff }", Convert.ToDateTime(dt.Rows[0][0].ToString()));
}
con.Close();
//insert_button
for (int i = 0; i < GridView1.Rows.Count; i++)
{
GridViewRow row = GridView1.Rows[i];
OpenConnection(con);
str = "insert intoemp (calldate,userfield) values('" + row.Cells[0].Text + "','" + row.Cells[1].Text + "','" + row.Cells[2].Text + "')";
SqlCommand com = new SqlCommand(str, con);
com.ExecuteNonQuery();
con.Close();
}
pls give the solution,
thanks.