TheMagician Posted November 12, 2003 Posted November 12, 2003 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 Quote
tate Posted November 12, 2003 Posted November 12, 2003 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.