Results 1 to 5 of 5

Thread: Querying my Project's Data Source ONLY

Hybrid View

  1. #1
    Lively Member blacksaibot's Avatar
    Join Date
    Jan 09
    Location
    East Coast, USA
    Posts
    94

    Querying my Project's Data Source ONLY

    I have a MS Access database file that I imported into my project as a data source. It's visible in my solution explorer.

    I have a DataGridView in my form whose data source is set to that imported access file.

    How can I set up my OleDbConnection (dim con) to be that data source?
    Right now I have con set to the actual file access database file, but when I send queries, the changes are made to my actual access file, and not the data source within my project!

    Dim con as OleDbConnection = new OleDbConnection("***database.mdb")

    Within the above *** string it points to the databasefile located on my hard drive that I imported into my project. But when I send queries to my DataGridView it makes those changes on the file, not on the data source that I bound to the DGV.

    I need a way to keep all the querying to one database... maybe have them linked?

    THe problem is that when customers use this program, they will be given updated versions of the database file with new data.

    When this program is finally compiled and sent out for use, how can they get the new data without having to reinstall the program? Is it possible that they just recieve the XSD file or what?

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 02
    Posts
    21,655

    Re: Querying my Project's Data Source ONLY

    the XSD file is just a design time file. Your users will never see it. If you want to give them an updated database, you give them a new mdb file and copy it over the old one. The data source points to the Access file... it's not some magical data storage... it's a gateway. Allows you to see what databases you are connected to. So, yeah, you make changes to your data, it's going to update the database. That's the idea.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.-I also subscribe to all threads I participate, so there's no need to pm when there's an update.*
    *Proof positive that searching the forums does work: View Thread *
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *
    * Use Offensive Programming, not Defensive Programming. * On Error Resume Next is error ignoring, not error handling(tm).
    "There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN

  3. #3
    Lively Member blacksaibot's Avatar
    Join Date
    Jan 09
    Location
    East Coast, USA
    Posts
    94

    Re: Querying my Project's Data Source ONLY

    When I change the datasource property of the DGV to be the database file, it doesn't make changes to the actual database, only the database file imported into the project.

    How do I make it so the changes are to the actual database file?

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 02
    Posts
    21,655

    Re: Querying my Project's Data Source ONLY

    Personally, I never use the Data Source thing... I make all my connections manually...
    ADO.NET works in a disconnected state by default... so changes you make aren't propagated back to the database until you tell it to do so (either by looping through the data, and running update queries, or by calling the .Update method of a properly connected and configured dataset/table.)

    If you haven't done so, I suggest reading through the ADO.NET section of the database FAQ...
    http://www.vbforums.com/showthread.php?t=337051

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.-I also subscribe to all threads I participate, so there's no need to pm when there's an update.*
    *Proof positive that searching the forums does work: View Thread *
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *
    * Use Offensive Programming, not Defensive Programming. * On Error Resume Next is error ignoring, not error handling(tm).
    "There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN

  5. #5
    .NUT jmcilhinney's Avatar
    Join Date
    May 05
    Location
    Sydney, Australia
    Posts
    80,785

    Re: Querying my Project's Data Source ONLY

    In short, whether you use a DataAdapter or a TableAdapter, you call Fill to populate a DataTable, edit the data, then call Update to save the changes. A TableAdapter is just a typed wrapper for a DataAdapter. You can either write all the code yourself or let the system do it for you but, either way, the data is retrieved and saved the same way.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •