C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » ADO.NET »

Insering Values in to Database


Posted Date: 12 Oct 2008    Resource Type: Code Snippets    Category: ADO.NET
Author: DharmarajMember Level: Diamond    
Rating: 1 out of 5Points: 5



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()




Responses

Author: Shashikant Kothavale    20 Oct 2008Member 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


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Inserting data in Database  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Storing login information in XML file
Previous Resource: Connecting MySQL with C#
Return to Discussion Resource Index
Post New Resource
Category: ADO.NET


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use