• 0

VB.NET and Access 2000 DB's


Question

im trying to re-write an application that is rather dated (VB6 and Access 97)

but im not sure how to go about sending my data to the DB and Retrieving it

from the DB in VB.NET.

does anyone know of some really good tutorials online i can look at for this?

or perhaps if someone wanted to be really awsome could write me an example

code.

either way i will be super grateful!

- D :happy:

Link to comment
https://www.neowin.net/forum/topic/226856-vbnet-and-access-2000-dbs/
Share on other sites

8 answers to this question

Recommended Posts

  • 0

I recently had to do a project using VB.NET and Access. I haven't the time to write any example code but here are a few classes that should get you started, and they are quite easy to use:

in System.Data.OleDb

OleDbConnection = makes connection to database

OleDbCommand = Allows you to use SQL

OleDbDataReader = Good for reading SQL SELECT queries

  • 0
  JadeWolf324 said:
is access and SQL conisdered the same thing in VB.NET programming?

I have dodged Access programming all the way though, so I am not sure how similar it is, but in VB.NET you have to use the classes provided by the .NET framework.

In the OleDbCommand class, you can put SQL commands into it, like so:

  Quote
Dim command as OleDbCommand = new OleDbCommand("SELECT * FROM MyTable", myConnection)

Dim reader as OleDbDataReader = command.ExecuteReader()

SQL is SQL, no matter what language you use.

  • 0

Hi this is short example how to connect to MS Access DB and retrieve the records from ... follow me

  Quote
this is part of the book MS VB.NET step by Step

1. Start Visual Studio .NET, and create a new Visual Basic Windows Application project named My ADO Form

2. On the View menu, click the Server Explorer command

3. Click the Connect To Database button in Server Explorer

4. Click the Provider tab in the dialog box

5. Click Microsoft Jet 4.0 OLE DB Provider on the Provider tab

6. Click the Next button to display the Connection tab of the Data Link Properties dialog box

7. Click the ellipsis button next to the Select Or Enter A Database Name field, select the your.mdb database

8. Click the Test Connection button on the Connection tab

9. Click OK in the Test Connection Succeeded message box to continue, and then click OK in the Data Link Properties dialog box

10. Open the Data Connections node, the ACCESS node, and finally the Tables node in Server Explorer

Creating a Data Adapter

1. Open the Toolbox, and click the Data tab

2. Drag the OleDbDataAdapter control from the Data tab of the Toolbox to the form

3. Read the opening statement about data adapters, and then click Next

4. Click Next to continue configuring the data adapter

5. Click Next to accept the Use SQL Statements option

6. Click the Query Builder button to build your SELECT statement graphically

7. Click (your intended columns name that want to appear), click Add, and then click Close

8. In the table, click the check boxes next to the columns you want to use for further i.e. nameID and secondName

9. Click OK to complete the SELECT statement

10. Click the Finish button

Working with Datasets

1. Click the form to make sure that it?s active

2. Click the Generate Dataset command on the Data menu

3. In the New box, set the name of the new dataset to (your choice)

4. Verify that the Add This Dataset To The Designer check box is selected so that Visual Studio will add the new dataset to the component tray

5. Click OK to create a dataset for the Instructor field and add it to your projecUsing Bound Controls to Display Database Information on a Formb>

1. Use the TextBox control to draw a text box object in the middle of the form

2. Use the Button control to draw one button object in the lower left corner of the form

3. Click the text box object on the form, and then open the Properties window

4. Open the DataBindings category, click the Text property, and then click the drop-down arrow

5. Click the plus sign (+) to expand thyourb> dataset, and then expand thyour b>table beneath it

6. Click the intended field to select it as the field that will be displayed in the text box. Be sure to click the "name" text and not the icon; otherwise, the your field won?t be selected.

9. Restore the Properties window, double-click the button, and then type the following program code in the button1_Click event procedure of the Code Editor:

dataSet1.Clear()
OleDbDataAdapter1.Fill(your item)

that's all

i hope it works ... i've done this hunderts times and it works great for me

kind regards

  • 0
  Quote
all have slightly different implimentations of SQL, along with custom datatypes and commands

it could be true but not in whole i.e. MS SQL Server has T-SQL that has some additional power but generally when you use "Insert" "Select" and "Update" SQL is same for all database whatever server or file DB ..... so if you work within SQL Server it's true that SQL is different and if you make stored procedures but within VB.NET IDE or whatever else process is same ... FoxPro has many differency inside its SQL structure (language) but if you want to select item from .. you use same SQL statement "SELECT * FROM" as with MS Access DB

kind regards

  • 0
  jugomkd said:
Hi this is short example how to connect to MS Access DB and retrieve the records from ... follow me

is this for writing to or reading a Access DB? i cant quite understand? but that has been VERY helpful. alot more

than anything else.

  • 0

This was to select items and show them in TExtBox windows form ..... by the way example doesn't stop here but it continues further with prev/next butons also first/last etc. but mainly you got the idea ...when you ones have your connection established and dataset filled with records from your db you can do whatever you like with 'em ... means Select, Insert, Update and whatever else ... i hope you understand this ... my english is not very well .... lol

Kind regards

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • anyone know of any VNC viewers that can do a full 4k and scaling to a mac from windows? RDP does it fine from a mac to windows and windows to windows... but I can't seem to get it to do 4k with UltraVNC and have it scaled to match from windows to the mac
    • At least on Mint... Debian is the 'backup' option (i.e. LMDE6) where as regular Mint is Ubuntu. also, Debian tends to play stuff a bit more conservatively than Ubuntu (at least based on Mint) with kernel and programs. also, even Mint's 'Update Manager' is more refined in regular Mint vs LMDE6 and installing NVIDIA driver is easier on regular Mint etc. not only that but LMDE6 only comes with Cinnamon which is a shame as they should offer the option for Xfce. I realize playing around with it in a VM one can install Xfce on it but it would be nice to have a more official Xfce release like how the regular Mint does. so while I heard Debian is a little snappier than Ubuntu (so better on some level), Ubuntu is probably the overall wiser choice unless people don't mind using a bit older stuff etc. but honestly, with some tweaks I would not mind if they changed the main Mint to Debian base instead of Ubuntu. but that's probably not likely to happen unless Ubuntu really does something the Mint team does not like. p.s. but I was building Super Mario 64 (native PC port on Linux) a while ago and it does not like regular Mint but works fine on LMDE6. but at that point I just transferred the final binary out of the VM back to my regular Mint and it works fine.
    • Excel is getting a highly requested PivotTable feature by Usama Jawad Microsoft Excel is one of the most popular software out there, both in the enterprise and personal space. It has a variety of use-cases including data analysis, data crunching, visualizations, and even planning and organization assistance. Microsoft regularly updates Excel with new features, and now, it is introducing a notable feature for PivotTables. Prior to today, PivotTables required a manual refresh from the user whenever new data was inserted into them. This wasn't a particularly complicated process, but it was tedious, so based on significant user feedback, Microsoft has decided to implement auto-refresh capabilities in PivotTables. The good thing is that Auto Refresh is enabled for all new PivotTables by default, but you can choose to disable it by selecting a PivotTable, navigating to the PivotTable Analyze tab, and then clicking on Auto Refresh. It is important to note that Auto Refresh is applicable on a per data source level, which means that the feature's state (on or off) will apply to all PivotTables derived from that source. Additionally, if Auto Refresh is disabled or a PivotTable is unable to synchronize, a message at the bottom of your workbook will say "PivotTable Refresh Needed". Once you click on it, all outdated PivotTables will refresh. Finally, you should keep in mind that external and asynchronous data sources do not support Auto Refresh and that the feature may become unavailable when a co-author is using an older version of Excel or if you are playing around with volatile functions like RAND() and NOW() in your data source. Auto Refresh for PivotTables is available right now in the Beta Channel for Excel for Windows version 2506 (Build 19008.2000) or later, and Excel for Mac version 16.99 (Build 250616106) or later. If you don't see it yet, it's better to wait as new capabilities are often rolled out in a staggered manner.
    • Hell of a legacy, hell of a bad person...
    • Man, what a legend. I know a lot of you don't like social media but the outpouring on the platforms has been really something else.
  • Recent Achievements

    • First Post
      Electronic Person earned a badge
      First Post
    • Week One Done
      CyberCeps666 earned a badge
      Week One Done
    • Very Popular
      d4l3d earned a badge
      Very Popular
    • Dedicated
      Stephen Leibowitz earned a badge
      Dedicated
    • Dedicated
      Snake Doc earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      627
    2. 2
      ATLien_0
      241
    3. 3
      Xenon
      163
    4. 4
      neufuse
      128
    5. 5
      +FloatingFatMan
      124
  • Tell a friend

    Love Neowin? Tell a friend!