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.
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?
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.
Re: How to insert data from DatagridView to MS Access Database
Originally Posted by blueye89
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.
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?
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?
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?
Re: How to insert data from DatagridView to MS Access Database
Originally Posted by blueye89
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.
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.
Re: How to insert data from DatagridView to MS Access Database
Originally Posted by blueye89
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.