C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Insering Values in to Database


Posted Date: 12 Oct 2008    Resource Type: Code Snippets    Category: ADO.NET

Posted By: Dharmaraj       Member Level: Diamond
Rating:     Points: 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  
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!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use