By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,166 Members | 1,575 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,166 IT Pros & Developers. It's quick & easy.

Accessing Access

P: n/a
I'm looking for the simplest example of VB.net to read/write a minimal MS
Access.database. Something like put date in textbox1, click button1, get
rainfall total in textbox2. For updates, fill in textboxes 1&2 and click
button2 to store new data in Access.

No creating classes or objects. Just a clean, quick and dirty example so I
can figure this out. Many Thanks.
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Stephen,
There are a number of samples in the Visual Basic.Net Resource Kit, that you
can download (free) from Microsoft or can get on CD.

But to get the simple solution you are asking for, you might prefer to use
Access IDE as the User Interface to the Access (MDB) database, rather than
Dot Net.

Also I am using a book "Visual Basic .NET COMPLETE" from SYBEX. It isn't a
great book if you are starting from scratch but if you have some VBA or VB
knowledge it gives some explanation and examples to move to Dot Net.

Doug
"Stephen" <sw******@notmail.com> wrote in message
news:OA**************@TK2MSFTNGP14.phx.gbl...
I'm looking for the simplest example of VB.net to read/write a minimal MS
Access.database. Something like put date in textbox1, click button1, get
rainfall total in textbox2. For updates, fill in textboxes 1&2 and click
button2 to store new data in Access.

No creating classes or objects. Just a clean, quick and dirty example so I
can figure this out. Many Thanks.

Nov 21 '05 #2

P: n/a
I just knocked up this example, which uses the northwind database. The text
box will display Nancy ( one of the employees ) hope this helps.

Dim ConStr As String = "Provider = Microsoft.Jet.OLEDB.4.0;Data
Source=..\Northwind.mdb;User Id=admin;Password="
Dim SelectString As String
Dim Con As New OleDb.OleDbConnection
Dim SelectCmd As New OleDb.OleDbCommand
Dim Da As New OleDb.OleDbDataAdapter
Dim Table As New DataTable

SelectString = "SELECT * FROM EMPLOYEES"
SelectCmd.CommandText = SelectString
SelectCmd.Connection = Con

Da.SelectCommand = SelectCmd
Con.ConnectionString = ConStr
Try
Con.Open()
Da.Fill(Table)

Catch ex As OleDb.OleDbException
MessageBox.Show(ex.Message)
Finally
Con.Close()
End Try

Me.TextBox1.Text = Table.Rows(0).Item(2).ToString()

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Stephen" <sw******@notmail.com> wrote in message
news:OA**************@TK2MSFTNGP14.phx.gbl...
I'm looking for the simplest example of VB.net to read/write a minimal MS
Access.database. Something like put date in textbox1, click button1, get
rainfall total in textbox2. For updates, fill in textboxes 1&2 and click
button2 to store new data in Access.

No creating classes or objects. Just a clean, quick and dirty example so I
can figure this out. Many Thanks.

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.