Results 1 to 13 of 13

Thread: How to insert data from DatagridView to MS Access Database

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2012
    Posts
    49

    How to insert data from DatagridView to MS Access Database

    Hello my friends, I made some application which fill an DatagridView with some data and I need the easiest way to make an ms access file and import all data from DatagridView in it.After that I will have saved ms database which I will use for some other applications.

  2. #2
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,684

    Re: How to insert data from DatagridView to MS Access Database

    Hello,

    When you say make an ms-access file do you want to create a new ms-access?
    Also would you be using a known table structure .i. field names and field types?

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2012
    Posts
    49

    Re: How to insert data from DatagridView to MS Access Database

    Yes of course, I want to create an ms-access file that will contains all data from my datagridview. I am trying to find specific words which represent my idea to convert all data from DG to ms-access file. That's all what I need.

  4. #4
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,684

    Re: How to insert data from DatagridView to MS Access Database

    Quote Originally Posted by blueye89 View Post
    Yes of course, I want to create an ms-access file that will contains all data from my datagridview. I am trying to find specific words which represent my idea to convert all data from DG to ms-access file. That's all what I need.
    When you say of course being here long enough I know to ask first as many people posting here can mean different things by this statement which is why I asked. To you this is clear but not to be hence the reason for asking.

    The attached VS2010 project upgraded from a VS2008 project shows how to create a new MS-Access 2003 database, create a table, populate the table and show the table schema. This gives you the tools to build upon.
    Attached Files Attached Files

  5. #5

    Thread Starter
    Member
    Join Date
    Feb 2012
    Posts
    49

    Re: How to insert data from DatagridView to MS Access Database

    Thank you very much!

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: How to insert data from DatagridView to MS Access Database

    kevininstructor is right to be sceptical. It is very unusual that an application would actually create the Access data file. The far more common course of action is that you create the MDB or ACCDB file as part of the application development process and then distribute it with your application. Is there a particular reason that you're not doing that?

  7. #7

    Thread Starter
    Member
    Join Date
    Feb 2012
    Posts
    49

    Re: How to insert data from DatagridView to MS Access Database

    In fact, I just need to connect an application which will allow me to update database periodically,and after when I load my application using shortcut, last changes will be loaded.
    Any idea?

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: How to insert data from DatagridView to MS Access Database

    You're not giving us clear answers to our questions. Are you going to create the Access data file yourself and distribute it with your application or do you want the application to be able to create the Access data file in code?

  9. #9

    Thread Starter
    Member
    Join Date
    Feb 2012
    Posts
    49

    Re: How to insert data from DatagridView to MS Access Database

    I want to create the Access data file and distribute it with my application. Periodically I will update that access data trough my application.Clear?

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: How to insert data from DatagridView to MS Access Database

    Quote Originally Posted by blueye89 View Post
    I want to create the Access data file and distribute it with my application. Periodically I will update that access data trough my application.Clear?
    Not necessarily 100%. You're still saying that you want to create an Access file. Have you already done so, i.e. do you have Microsoft Access installed and have you used it to create either an MDB or ACCDB file and added it to your project? I suspect the answer is "yes" but, given the ambiguity of your previous posts, maybe not.

  11. #11

    Thread Starter
    Member
    Join Date
    Feb 2012
    Posts
    49

    Re: How to insert data from DatagridView to MS Access Database

    Do you have Microsoft Access installed and have you used it to create either an MDB or ACCDB file and added it to your project?
    My answer: I have installed ms access but I have no created ms-access file. But, you gave me idea, I just need to make empty database and putting it into my project as resource file. Always when I load my application,database will be loaded into my application and I will be able to change,update or remove some data and replace that changes on database.

  12. #12
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: How to insert data from DatagridView to MS Access Database

    Quote Originally Posted by blueye89 View Post
    I just need to make empty database and putting it into my project as resource file.
    No, not a resource. Just create the MDB or ACCDB file and then right-click your project in the Solution Explorer and select Add > Existing Item. You then select your data file and, when prompted, have it copied into your project. You can now forget the original data file you created because your source database is now in your project folder. Select it in the Solution Explorer and set its Copy To Output Directory property to Copy If Newer. Now you are in the same position as basically everyone who uses Access databases. When you deploy your app, a clean copy of your database goes with it. Follow the first link in my signature to learn how local data files are managed.

  13. #13

    Thread Starter
    Member
    Join Date
    Feb 2012
    Posts
    49

    Re: How to insert data from DatagridView to MS Access Database

    Thank you my friend. I will do it and if I have some questions in future I will be back. Thanks again.

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width