473,403 Members | 2,323 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Adding Data to Ms Access Database by VB.NET

Hi guys,

I have created database using ms access & i have ceated a form using vb.net.
i want to do this. when i enter the data to the form & after that click Submit button the data must be enter in to the database.
Please tell me how to do that.
If you can tell me the coding.
Thanks a lot
Sep 18 '07 #1
2 5772
r035198x
13,262 8TB
Hi guys,

I have created database using ms access & i have ceated a form using vb.net.
i want to do this. when i enter the data to the form & after that click Submit button the data must be enter in to the database.
Please tell me how to do that.
If you can tell me the coding.
Thanks a lot
Hi and welcome to TSDN. Hope you'll have a great time here.
I've moved this to the .NET forum for now.
Sep 18 '07 #2
Hi,

Here's a sample code for accessing and inserting data into Ms Access.

Dim strPathFileName as string="C:\myAccess.mdb"
Dim strCmdTxt as string=""

Dim CN As New System.Data.OleDb.OleDbConnection
Dim ObjDA As New System.Data.OleDb.OleDbDataAdapter
Dim InsertCmd As New System.Data.OleDb.OleDbCommand
CN.ConnectionString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database L" & _
"ocking Mode=1;Data Source=""" & strPathFileName.Trim & """;Mode=Share Deny None;Jet OLED" & _
"B:Engine Type=5;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Je" & _
"t OLEDB:SFP=False;persist security info=False;Extended Properties=;Jet OLEDB:Com" & _
"pact Without Replica Repair=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Cre" & _
"ate System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;User ID=A" & _
"dmin;Jet OLEDB:Global Bulk Transactions=1"

strCmdTxt = "INSERT INTO EmployeeInformation("
strCmdTxt &= "FirstName,"
strCmdTxt &= "LastName,"
strCmdTxt &= "EmployeeID"
strCmdTxt &= ") VALUES ("
strCmdTxt &= "'" & strFName & "',"
strCmdTxt &= strLName & ","
strCmdTxt &= intEmpID
strCmdTxt &= ")"

InsertCmd.CommandText = strCmdTxt
InsertCmd.Connection = CN
InsertCmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("FirstName", System.Data.OleDb.OleDbType.VarWChar, 30, "FirstName"))
InsertCmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("LastName", System.Data.OleDb.OleDbType.VarWChar, 30, "LastName"))

InsertCmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("EmployeeID", System.Data.OleDb.OleDbType.Integer, 0, "EmployeeID"))
InsertCmd.CommandText = strCmdTxt.Trim
InsertCmd.Connection = CN
ObjDA.SelectCommand = InsertCmd
CN.Open()
'execute insert command
InsertCmd.ExecuteNonQuery()

For your reference. enjoy!

Best regards,
Ruel
================================================== ==
Hi guys,

I have created database using ms access & i have ceated a form using vb.net.
i want to do this. when i enter the data to the form & after that click Submit button the data must be enter in to the database.
Please tell me how to do that.
If you can tell me the coding.
Thanks a lot
Sep 19 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Anand | last post by:
Hi i am having trouble adding a recordset into the access database, the code seems to be working fine it passs and parses through all variables just fine without showing any errors and also when i...
1
by: Jonnie | last post by:
I am in the process of building an employee database for use by the management team here. They current have Access 97 (I am working on getting them to upgrade to at least 2000). For the most part I...
5
by: Nicolas Mejia | last post by:
Hello: I´m not a professional programer in Access. I´m working in a proyect that will permit me add my flight time, but I have been having problems with the time adding. Please can some one...
3
by: ET | last post by:
I don't know whats the problem, but after I added functions to first verify, then relink linked tables if not found, now I can't convert that database to MDE format. I can split the database, but...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
12
by: Art | last post by:
Hi everyone I was hoping someone might be able to help me with this. I'm just starting to try to work with MS Access tables through VB.net. In Access I can take an existing table and add a new...
8
by: shumaker | last post by:
I'm wondering if adding an autonumber primary key will improve the performance of a multiuser access database on a network share. I have a website that lists many tips for improving performance of...
7
by: Miro | last post by:
Im a VB Newbie so I hope I'm going about this in the right direction. I have a simple DB that has 1 Table called DBVersion and in that table the column is CurVersion ( String ) Im trying to...
2
by: Steve | last post by:
I have zero experience with ODBC. If I have an Access frontend connected to a SQL Database using ODBC, are the tables connected like a frontend/backend Access database where the the tables you see...
6
by: teddysnips | last post by:
I'm having trouble adding Access 2003 databases to Sourcesafe. I go to Tools, Sourcesafe, Add Database to Sourcesafe... at which point a message box appears saying "This database must be closed...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.