Accessing Access

  • Thread starter Thread starter Stephen
  • Start date Start date
S

Stephen

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.
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top