4
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by crishlay
0

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 + "')";
SqlDataSource1.Insert();
Now, run the page
type something in textbox and click on button, it will insert the value in the database. OK.

0

hi

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

than
on button click event

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


may be this can help you
thanx

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.