backend (sqlserver) insert /update

Posted by Dn2010 under ASP.NET on 4/6/2012 | Points: 10 | Views : 1138 | Status : [Member] | Replies : 3
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.




Responses

Posted by: Rajni.Shekhar on: 4/6/2012 [Member] Bronze | Points: 25

Up
0
Down
What you want to know? i mean where you stuck? tell us briefly.

Thanks,
Rajni Shekhar

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 4/9/2012 [Member] Starter | Points: 25

Up
0
Down
hi,
first of all u can clear old values after that again bind the values.
then u'l get gud result.

Try it.

Thanks & Regards
Hari

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 4/10/2012 [Member] Bronze | Points: 25

Up
0
Down
Dn2010
Tell Clearly .... Our DotnetfundaTeam Will Help U..

:)

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response