Hi, i am using ASP.NET.I want to insert command in asp.net using c#.How can i do?? thanx

Drag a textbox, a button and a SqlDataSource control on the page
Create connection in sqldatasource control. If you dont know how, then follow these steps-:
Near the top-right corner of SqlDataSource control, there is a very small box containing a black symbol '>', click on that.
Then click on Configure DataSource.
Click on New connection.
type the server name and database name (and username and password also if required)
click OK
click next,next.
select the table and click on *.
click Finish.
Now, on the button click event, type the following command-:
SqlDataSource1.InsertCommand = "insert into table1(column1) values('" + TextBox1.Text + "')";
Now, run the page
type something in textbox and click on button, it will insert the value in the database. OK.


first create a connection to database like
sqlconnection con=new sqlconnection("//type here your connection string");

on button click event

string qry="insert into tablename(id,name)values('"+textbox1.text+"','"+textbox2.text+"')";
sqlcommand cmd=new sqlcommand(qry,con);

may be this can help you