Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Connecting to access database using vb.net with codes

RhodenRhoden Posts: 3Member
I want to connect to an access database using vb.net 2008 version. I would really like and appreciate your assistance. I want to connect to the access database using codes.

Thank you much!
«1

Comments

  • bradwangbradwang Posts: 197Member
    Here is the code snippet:

    Dim cn As New OleDbConnection
    cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|Data.mdb;Persist Security Info=True"
    cn.Open()
    cn.Close()

    Also, you can study this tutorial:
    http://www.geekpedia.com/tutorial158_Connect-to-Access-Database-in-Visual-Studio-.NET.html

    Finally, I suggest that you find a good book or a tutorial on ADO.NET. :)

    [color=Green][size=1][b]Brad Wang - .NET Freelancer from China
    MSN: brad_wang_cn@hotmail.com
    Skype: brad_wang[/b][/size][/color]
  • RhodenRhoden Posts: 3Member
    Thank you Brad Wang. I really appreciate your response.
  • tangsemtechtangsemtech Posts: 4Member
    : Thank you Brad Wang. I really appreciate your response.
    :

    Happy learning .NET :)
  • LumirrisLumirris Posts: 1Member

    :
    : Finally, I suggest that you find a good book or a tutorial on
    : ADO.NET. :)
    :


    Along those lines, can anyone recommend such a book and/or tutorial? I need to learn ALL about this, from the very beginning ;)

    I've already finished a "Get an intro to VB.NET in 24 hours" type book.

    Thanks!
    Jeff
  • bradwangbradwang Posts: 197Member
    :
    : Along those lines, can anyone recommend such a book and/or tutorial?
    : I need to learn ALL about this, from the very beginning ;)
    :
    : I've already finished a "Get an intro to VB.NET in 24 hours" type
    : book.
    :
    : Thanks!
    : Jeff
    :


    I heard that book - "Get an intro to VB.NET in 24 hours" is a nice one.

    Beside, you can checkout a nice list of VB.NET books for beginners here:
    http://visualbasic.about.com/od/vbnetbeginnerbooks/l/blgtvbbegina.htm


    [color=Green][size=1][b]Brad Wang - .NET Freelancer from China
    MSN: brad_wang_cn@hotmail.com
    Skype: brad_wang[/b][/size][/color]
  • WilliamRich1WilliamRich1 Posts: 5Member
    Please forgive me for cutting into your discussion...

    I'm in a situation where I'm sold on Visual Studio 2008 and VB.NET, but my organization is balking at providing SQL Server access. I know that an Access 2007 data-only database can be hosted on common server in the usual way and then connected to with a VB.NET app via ADO.NET. My question is if there is a SQL engine in the mix to be found? Can I send SQL queries to the Access back end?

    Thanks in advance for your time.

  • seancampbellseancampbell Pennsylvania, USAPosts: 684Member ✭✭✭
    http://www.programmersheaven.com/mb/VBNET/386345/386345/program-demonstrating-ms-access-database-manipulation/?S=B20000

    There is a link to a post I wrote to demonstrate how to manipulate data in an Access DB with the OleDB.OleCOnnection objects. You can supply a network path (\servernamedrive$foldersetc) to the Connection String and it will connect to the data, and you can execute SQL Queries against the data with the associated objects as well.

    Give it a peak, if you have any questions about it start a new thread.

    -Sean C
  • WilliamRich1WilliamRich1 Posts: 5Member
    Thank you Sean. I had grown fond of using Access 2003 to rapid protype but was very turned off by Access 2007. I like the idea of using all the flexiblity of VB.NET and Visual Studio yet get away with the light organizational foot print of slipping the back-end Access "data" database onto some unsuspecting managers server. Of course, having a proper SQL Server host is the way to go. Fortunately our workstations are well maintained and have the 3.5 framework. I'm sure when my Unix legacy product based company gets a taste of the modern .NET tools they will let me put together an de facto development group nad begin to build a new product support infrastructure.

    Hey, I sure like the Express products and am generally blown away by all the high-quality free videos available today. It looks like anyone with a few dollars a month for a proper hosting service plus SQL Server and Visual Studio Express can compete with anyone.

    Thanks again Sean, and happy coding to you to sir!

    Wm
  • WilliamRich1WilliamRich1 Posts: 5Member
    I looked over the examples supplied but they appear to only support CRUD actions against the Access database. Could you show how to code for a SQL query and explain how and where the processing occurs?
  • seancampbellseancampbell Pennsylvania, USAPosts: 684Member ✭✭✭
    The example I provided is very basic, but the objects which I use provide methods to do nearly anything you'd want with your database.

    It does demonstrate the basic CRUD commands (Create, Read, Update, Delete) and also has an example of Inserting new rows (or is that included in CRUD's description).

    The OleDBCommand provides you with means to directly execute SQL code, through which you can execute stored procedures, use Formulas inside of your queries (to return sophisticated results), and even get results spanning multiple tables of return... I'm not sure what additional functionality you're expecting to have over the database besides having a premade GUI interface to manipulate your DB (actually, VisualStudio provides that with the Server Explorer).

    That said, move to the code block I have in that example called "Private Sub btnSave_Click" underneath this function I call a NonQuery SQL statement to update or insert a record using SQL Parameters. The OleDbCommand object is used to create and execute SQL statements either predefined or dynamically generated. My example should explain how to use the object explicitly, let me know if you still don't understand it after you read the comments. Beyond this explanation I cannot elaborate as I am no expert, and if you want more detailed system explanation I'd direct you over to the MSDN which is wicked-awesome at giving that level of detail

    Happy coding
    -Sean C - firesickle.com
«1
Sign In or Register to comment.