473,805 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OT- Access Program stuck on little VB 2005 project

I normally only use A2000 but I need to do a little project in VB2005

But I can't figure out how to open the backend Access table in code and add
data using code. I don't need to bind to a form.
This is so simple in VBA but I have searched help, internet and 2 books and
have yet to find a working example for VB 2005

Does anyone have a simple sample of opening a table and adding data.

I know this an Access group but some here also work with VB 2005

Jul 24 '07 #1
5 2535
Hi, Karl.
>I normally only use A2000 but I need to do a little project in VB2005

But I can't figure out how to open the backend Access table in code and
add data using code.
For a quicker answer, I suggest you post your question in a VB .Net
newsgroup that focuses on databases.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
http://www.Access.QBuilt.com/html/ex...ributors2.html for contact
info.
Jul 25 '07 #2
Hi Karl,

This is a piece of cake

--------------------------------------------
Imports System.Data.Ole Db
Imports System.Data
Imports System.IO

Public Class Form1

Dim conn As OleDbConnection , da As OleDbDataAdapte r
Dim ds As DataSet, curMgr As CurrencyManager

Private Sub Form1_Load(...) Handles MyBase.Load

conn = New OleDbConnection
conn.Connection String = "provider=micro soft.jet.oledb. 4.0; Data Source =
C:\someDir\db1t est.mdb"
da = New OleDbDataAdapte r
ds = New DataSet
da.SelectComman d = New OleDbCommand
da.SelectComman d.Connection = conn
da.SelectComman d.CommandType = CommandType.Tex t
da.SelectComman d.CommandText = "Select * from yourTbl"
da.Fill(ds, "tbl1")
curMgr = CType(Me.Bindin gContext(ds.Tab les("tbl1")), CurrencyManager )
curMgr.Position = 0
'--tssL3.Text = curMgr.Count.To String
'--tssL2.Text = (curMgr.Positio n + 1).ToString
dgrv1.DataSourc e = ds.Tables(0)

End Sub

End Class

--------------------------------------------

This is a basic sample for just reading data into a VB2005 app from an
Access mdb. As far as controls go, for this sample, start a new project
which will bring up Form1 by default. In Form1 add a statusStrip control
(from the toolbox) -- this is the replacement for the Statusbar control
-- lots more horsepower. Actually, if you want to simplify the example,
you can forgo the statusstrip and just comment out the lines of code for
tssL3... and tssL2...

But you will need to add a datagridview to the form. I named my
datagridview -- dgrv1. THen just copy and paste the code above. Just
replace the connection string path with a path to your mdb and replace
yourTbl with the name of a table in your Access mdb and then run the
sample. The datagridview will populate immediately with the data from
your Access table.

The CurrencyManager object "curMgr" is how you keep track of where you
are in your dataset. You display the record position in the labels in
the statusstrip. I named my labels tssL2 and tssL3. But just to run
the sample, you don't need the statusstrip.

Writing/editing data from your Access table is also pretty easy, but
I'll let you chew on this for a while first. Note: if the connection
string copies on 2 lines -- drag the 2nd line to the first line to make
it one line because in this sample I did not break the connection string
into 2 lines. And you do not need to add any additional objects like a
Dataset from the toolbox. The only control you need from the toolbox
for this sample is a Datagridview control. Drag one of those onto your
form and strech it out a little bit.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Jul 25 '07 #3
Few of us who participate in this newsgroup use DotNet. For the type
applications we do, single-user, modest-group-size multiuser, and
client-server on a LAN, Access is quicker and easier.

Thus, I think Gunny's advice is good, if your application is web-based. If
your application is an individual Windows app, or on a LAN, then perhaps you
ought to invest a little time and effort into investigating creating
database applications with Access itself.

Larry Linson
Microsoft Access MVP

"Karl" <so*****@sbcglo bal.bizwrote in message
news:Cd******** **********@news svr23.news.prod igy.net...
>I normally only use A2000 but I need to do a little project in VB2005

But I can't figure out how to open the backend Access table in code and
add data using code. I don't need to bind to a form.
This is so simple in VBA but I have searched help, internet and 2 books
and have yet to find a working example for VB 2005

Does anyone have a simple sample of opening a table and adding data.

I know this an Access group but some here also work with VB 2005

Jul 25 '07 #4
Thanks Rick

"Rich P" <rp*****@aol.co mwrote in message
news:46******** *************@n ews.qwest.net.. .
Hi Karl,

This is a piece of cake

--------------------------------------------
Imports System.Data.Ole Db
Imports System.Data
Imports System.IO

Public Class Form1

Dim conn As OleDbConnection , da As OleDbDataAdapte r
Dim ds As DataSet, curMgr As CurrencyManager

Private Sub Form1_Load(...) Handles MyBase.Load

conn = New OleDbConnection
conn.Connection String = "provider=micro soft.jet.oledb. 4.0; Data Source =
C:\someDir\db1t est.mdb"
da = New OleDbDataAdapte r
ds = New DataSet
da.SelectComman d = New OleDbCommand
da.SelectComman d.Connection = conn
da.SelectComman d.CommandType = CommandType.Tex t
da.SelectComman d.CommandText = "Select * from yourTbl"
da.Fill(ds, "tbl1")
curMgr = CType(Me.Bindin gContext(ds.Tab les("tbl1")), CurrencyManager )
curMgr.Position = 0
'--tssL3.Text = curMgr.Count.To String
'--tssL2.Text = (curMgr.Positio n + 1).ToString
dgrv1.DataSourc e = ds.Tables(0)

End Sub

End Class

--------------------------------------------

This is a basic sample for just reading data into a VB2005 app from an
Access mdb. As far as controls go, for this sample, start a new project
which will bring up Form1 by default. In Form1 add a statusStrip control
(from the toolbox) -- this is the replacement for the Statusbar control
-- lots more horsepower. Actually, if you want to simplify the example,
you can forgo the statusstrip and just comment out the lines of code for
tssL3... and tssL2...

But you will need to add a datagridview to the form. I named my
datagridview -- dgrv1. THen just copy and paste the code above. Just
replace the connection string path with a path to your mdb and replace
yourTbl with the name of a table in your Access mdb and then run the
sample. The datagridview will populate immediately with the data from
your Access table.

The CurrencyManager object "curMgr" is how you keep track of where you
are in your dataset. You display the record position in the labels in
the statusstrip. I named my labels tssL2 and tssL3. But just to run
the sample, you don't need the statusstrip.

Writing/editing data from your Access table is also pretty easy, but
I'll let you chew on this for a while first. Note: if the connection
string copies on 2 lines -- drag the 2nd line to the first line to make
it one line because in this sample I did not break the connection string
into 2 lines. And you do not need to add any additional objects like a
Dataset from the toolbox. The only control you need from the toolbox
for this sample is a Datagridview control. Drag one of those onto your
form and strech it out a little bit.

Rich

*** Sent via Developersdex http://www.developersdex.com ***

Jul 25 '07 #5
Sorry that should say Thanks Rich
Jul 25 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
3615
by: edgrsprj | last post by:
PROPOSED EARTHQUAKE FORECASTING COMPUTER PROGRAM DEVELOPMENT EFFORT Posted July 11, 2005 My main earthquake forecasting Web page is: http://www.freewebz.com/eq-forecasting/Data.html Newsgroup Readers: If you circulate copies of this report to groups of computer programmers at different universities etc. around the world then they might find the subject matter to be interesting.
49
14366
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The application is relatively big: around 200 tables, 200 forms and sub-forms, 150 queries and 150 repports, 5GB of data (SQL Server 2000), 40 users. I'm wondering what are the disadvantages of using Access as front-end? Other that it's not...
35
3228
by: deko | last post by:
Do I get more scalability if I split my database? The way I calculate things now, I'll be lucky to get 100,000 records in my Access 2003 mdb. Here some math: Max mdb/mde size = 2000 x 1024 = 2,048,000k Let's say on average each record in the database consumes 15k 2,048,000/15 = 136,533 records
5
3016
by: Bec | last post by:
I'm in desperate need of your help.. I need to build an access database and have NO idea how to do this.. Not even where to start.. It IS for school, and am not asking anyone to do my homework for me.. I am merely asking for help, perhaps pointers as to where to begin.. I've never used access before.. I'm rather cluey when it comes to
4
3541
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The objective in utilizing this new deployment method is to reduce the maintenance overhead as well as making it easier for my users to setup and run the application initially. I have VS 2002, Windows XP, Access XP(2000 format). He is my problem....
6
1208
by: HK | last post by:
I have ASP.NET 1.1 websites. They will need to access a SQL 2005 database. Do I have to upgrade the whole web projects to ASP.NET 2.0 in order for them to access SQL 2005? If so, anyone have any good URLs for upgrading 1.1 websites to 2.0? I'm really worried about crashing the current websites if I do a quick conversion to 2.0, but I don't have much time before needing to access SQL 2005.
17
4425
by: Mell via AccessMonster.com | last post by:
Is there a way to find out where an application was created from? i.e. - work or home i.e. - if application sits on a (work) server/network, the IT people know the application is sitting there, but is there a way they can find out if that application was put there from a CD or email or created at work? Hint: It's not on a client/server database, just native jet database mdb created on Access 2003 (default 2000)...
1
3730
by: lactaseman | last post by:
While I know this is not the correct venue... I realize this is of little to no importance to most out there... however, if I had found this in my initial searches, I would have used this. So, as an alternative to the mentalis.org's IniReader, I submit the following files to the web news group DBs...: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
6
2426
by: Wesley Peace | last post by:
I hate to cross post, but I've gotten no answer yet on a problem I'm having with visual studio 2008. I've created a series of forms with controls to access a Access database tables. The connection string works fine and the tables are added to the project without a problem. When I create the tables they appear to bind and I am able to preview the data in the database in design mode; however, at runtime no data is displayed and the...
0
9716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10607
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10359
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10104
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9182
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7645
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6875
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.