C# Tutorials and offshore development in India

Tutorials Resources Forum Reviews Interview Jobs Projects Training Your Ad Here


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...




Resources » Code Snippets » MS Access »

Insert data into MS-Access


Posted Date: 13 Jul 2009    Resource Type: Code Snippets    Category: MS Access
Author: Mohammad Sherif A MMember Level: Gold    
Rating: 1 out of 5Points: 5



Insert data into MS-Access in VB.net


This is an example which is best and very simple for inserting to an MS Access database.

1. First of all add a textbox and button.
2. Add these namespaces into the program before the start of the class

Imports System.Data
Imports System.Data.OleDb


3. Declare these variables in the form

Dim conn As OleDb.OleDbConnection
Dim cmd As OleDb.OleDbCommand


4. Add these on the button click event

cmd = New OleDb.OleDbCommand("insert into Table1 values(' " + TextBox1.Text + " ')", conn)
cmd.ExecuteNonQuery()

add this form load
Dim con As String = "Provider=Microsoft.JET.oledb.4.0;Data Source=H:\SPM\name.mdb"
conn = New OleDb.OleDbConnection(con)
conn.Open()


NOTE:Please dont forget to change database name and table name as per ur table.



Responses to the resource: "Insert data into MS-Access "
Author: iloveu    17 Jul 2009Member Level: Bronze   Points : 0
thanx... its rally working with these short codes... thanx a lot...


Author: Sundar    11 Oct 2009Member Level: Bronze   Points : 1
thanks its a very good help for the begginer level, application developer thanks a lot


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Best way to connect to MS Access database from VB.Net  .  

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: MS Access Query: Splitting Name field into First, Middle and Last Name
Previous Resource: Use Access Database in ASP.Net webForm
Return to Discussion Resource Index
Post New Resource
Category: MS Access


Post resources and earn money!
 
More Resources




About Us    Contact Us    Privacy Policy    Terms Of Use