Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi all

 

After some extensive searching, reading forums, and a whole lot of frustration - i put the plea out to this forum

 

I learnt my VB in VB6 and had fairly well sorted out the whole ado thing and could open access databases and do all the funky sql stuff, and was happy. Along comes vb.net, which in so many ways is very kewl. However, i CANNOT figure out how to do what i used to do with ado under the new ado.net framework (ie i'm not really even sure how to start - ie should i create a oledbconnection thing or do that programmtically etc)

 

Theres tutorials galore that show me how to do it with SQLServer but as for MS Access, I have no idea.

 

Basically what I want to do is to (however is best) get access to the different data in an MS Access Database (ie .mdb file) via SQL commands, and be able to use that to display on a form.

 

Can someone either direct me to a simple, well explained example on this, or even better! show me how!

 

Any help would be tremendously appreciated

 

Cheers, TheMagician

Posted

The general steps listed below should give you a good start;

 

 

 

Create connection

- Drag OleDbConnection tool (Data tab) to form

- Connection string property define the new connection string

- Provider tab, utilize Microsoft Jet 4.0 OLE DB Provider then Next

- Navigate to database file *.mdb

 

Create data adapter

- Drag the OleDbDataAdapter tool (Data tab) to form

- Select the connection just made above then Next

- Make sure SQL statements radio button is chosen then Next

- Select Query builder to add associated database table

- Select fields from chosen table

 

Generate the dataset

- Click Data pull down menu at top of screen, click generate dataset

- Enter name of dataset

- Choose table(s) to add to the dataset

 

Fill the dataset within Load event

 

Bind data to form control

 

************* Code Example *************************

 

Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

 

'Fill dataset

Dim intRecords As Integer

Dim bndTemp As Binding

 

intRecords = odbdaFactory.Fill(dsParts)

 

'Bind form's text boxes

 

bndTemp = New Binding("Text", _ dsParts, "tblParts.fldPartNumber")

 

txtPartNo.DataBindings.Add(bndTemp)

 

bndTemp = New Binding("Text", dsParts, "tblParts.fldDescription")

 

txtDesc.DataBindings.Add(bndTemp)

 

bndTemp = New Binding("Text", dsParts, "tblParts.fldCost")

 

txtCost.DataBindings.Add(bndTemp)

 

bndTemp = New Binding("Text", dsParts, "tblParts.fldSalesPrice")

 

txtSalesPrice.DataBindings.Add(bndTemp)

 

bndTemp = New Binding("Text", _ dsParts, "tblParts.fldQuantityOnHand")

 

txtQtyOnHand.DataBindings.Add(bndTemp)

 

End Sub

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...