I want to know how to add data into a database. Here's the details:
I have a sqldatasource(sqldatasource1) attached to a database with a table namedcustomers.
The table(customers) has one field named 'Name' with datatype varchar(50)
I have a textbox (textbox1) and a button (button1)
I want to insert the text into textbox1 into my database. how can i do that?Rather than giving you a point answer which will no doubt raise several other related questions, you will find the following link very useful in answering your question.
http://www.asp.net/Tutorials/quickstart.aspx
Navigate to Data Controls section and click on the SqlDataSource. The portion you want to review is the "Master-Details Insert" section all the way at the bottom of the page. You can run the sample program as well as view the source in both VB and C#.
Last bit of advice. When working with SqlDataSource, it's a good idea to create a Primary Key for the table involved. Without it, many operations can't be automatically defined (such as UPDATE, DELETE, INSERT sql generation). So, add that "CustID" column and make it the Primary Key for the table before doing anything else.
|||
Hi jcasp,
I'm feeling kinda stupid now that you have posted a link with (i assume) all the info i need, though by looking at the link you posted I'm still not sure how to do it..
Any chance that you could clarify?
Regards,
Snooze
|||Take a look at the following article. It will tell you all you need to know about working with DataSource control and Data Controls that bind to it.
http://aspnet.4guysfromrolla.com/articles/122904-1.aspx
No comments:
Post a Comment