473,385 Members | 1,337 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,385 software developers and data experts.

Inserting to an access database via visual studio

Hi,

am creating a web form in visual studio to insert data into an access database. The web form text boxes on the aspx file are Textbox.Text, Textbox2.Text and Textbox4.Text. The info is going to an access database i have in my app_data folder called users.mdb. The field names are Username, Password, Email_Address. The textbox data is being sent in the same order to the fields and textbox order listed above. Am fairly new to visual studio and asp.net. What code is required to submit this information to the access database.

Thanks
Mar 27 '08 #1
1 1429
balabaster
797 Expert 512MB
First up you need to make sure you have some imports in your codebehind at the top of your class so that you can reference your access database:

Imports System.Data
Imports System.Data.Oledb

The code is relatively simple
Expand|Select|Wrap|Line Numbers
  1. Dim oCon As New OledbConnection("ConnectionStringToAccessDB")
  2. oCon.Open()
  3. Dim oCmd As New OledbCommand("Insert into MyTable(Field1, Field2, Field3) Values @Value1, @Value2, @Value3", oCon)
  4. oCmd.Parameters.Add(New OledbParameter("Value1", "ValueToEnterIntoField1"))
  5. oCmd.Parameters.Add(New OledbParameter("Value2", "ValueToEnterIntoField2"))
  6. oCmd.Parameters.Add(New OledbParameter("Value3", "ValueToEnterIntoField3"))
  7. oCmd.ExecuteNonQuery()
  8. oCmd.Dispose()
  9. oCon.Close
  10. oCon.Dispose
Mar 27 '08 #2

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

Similar topics

63
by: Jerome | last post by:
Hi, I'm a bit confused ... when would I rather write an database application using MS Access and Visual Basic and when (and why) would I rather write it using Visual Studio .Net? Is it as easy...
11
by: olle | last post by:
Hi everyone. I am an Access developer having worked with Access-dev. projects for many years on Sql server databases and Access. For the internet I have been using traditional asp. But now I have...
5
by: hfk0 | last post by:
Hi, I'm new to ASP.net, SQL Server and visual studio.net, and I'm having problem inserting and storing data from a web form to a SQL database. I created a simple ASP.NET web form, a simple SQL...
18
by: surfrat_ | last post by:
Hi, I am having the following problems in getting Microsoft Visual Studio 2005 Professional to link to an Access .mdb database. Please help me to sort this out. Problem 1: The Microsoft...
5
by: Mo | last post by:
Hello all, I'm trying to set up an access 2000 .adp project connecting to a SQL server 2005 database. I can set up the connection ok, but once I have completed the setup process, I get the...
4
by: Cindy H | last post by:
Hi I am currently using Visual Studio.Net 2003 running on Windows Server 2000 operating system. I have used Visual Studio.net 2003 connecting to Access 2002 databases in the pass with great...
3
by: Surya | last post by:
Dear All, I have problem on inserting a record to database..Although it looked easy.. i have caught up with following issue .. please go ahead and help me to find solution I Need to insert...
6
by: ashes | last post by:
Hi, I am creating an ecommerce website using Microsoft Visual Studio, VB.Net and MS Access 2003. I am new to VB.Net When someone wants to register on the website, they fill out a form and the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.