In this chapter let us examine how to insert data into a table from a webform
Suppose we have a text box named 'sname' and a button named 'insert' .Our aim is to
insert the value in the text box to the table named 'reg' when the button is clicked
steps
1.Establish the connection
2.Double click on the button
Since the event is to happen when the button is clicked,the code for insertion should be written below buttons click event heading.When you double click on the button,you will be guided to this location
Code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click (No need to write the above line.It will be there)
con.open()
//open the connection
cmd.CommandType = CommandType.Text
cmd.CommandText = "insert into reg values('" & Me.sname.Text & "')"
//code to insert
cmd.ExecuteNonQuery()
con.Close()
e shtunë, 16 qershor 2007
Abonohu te:
Posto komente (Atom)
Nuk ka komente:
Posto një koment