Create a Table Contact with the following fields Name varchar(50) Mobile varchar(12) Email varchar(50) lastmodifiedts datetime status char(1) Create a vb.net windows application with three fields namely name,mobile and email. Drag two buttons in the form one is save and another one is cancel. In the form load event write the following code.
'In the form load event open the connection public sub Form1_Load() Dim con as new SqlConnection con.ConnectionString="Data Source=localhost;InitialCatalog=databasename;uid=sa;pwd=welcome" con.Open() end sub ' Now to save the details write this piece of code in the save button public sub btnSave_click() dim cmd as new SqlCommand cmd.CommandText="INSERT INTO Contact(Name,Mobile,Email) VALUES ('" & txName.Text & "','" & txMobile.Text & "','" & txMail.Text & "')" cmd.connection=con cmd.ExecuteNonQuery()
|
| Author: Shashikant Kothavale 20 Oct 2008 | Member Level: Silver Points : 1 |
public sub savedata
dim cmd as new sqlcommand("Insert into TableName (Field)values('Values whatever')",connectiononbject) connectiononbject.open() cmd.executenonquety) connectiononbject.close()
end sub
|