Ms Access & C++builder4
I'm reposting this just in case that someone that may be able to help may have missed it. (no disrespect intended)
I was wondering can anyone help me. I want to access tables in MS Access through C++Builder. I know how to do it in VB and I was wondering if it is the same?
If you know I'd much appreciate it.
Thanks in advance,
excellent question, This isn't an answer but i hope someone can answer, how to access a database with C++
It's not quite as simple as it is in VB, but it's not too bad. Now, I use Builder 5, not 4, but it's probably the same.
You must go through control panel and click "ODBC Data Sources". Under the User DSN tab, choose Add. Then pick the MS Access driver. Then you'll want to type in a descriptive name where it says "Data Source Name" because this will serve as your alias. Next, choose Select and get the path where your Access db is located. Click OK and you're done. When you try to use an Access db, it will probably prompt you for a username and password (at least Builder 5 does). The deafult is "admin" for the username with no password. You can choose your own password and username under the Advanced button where to selected the path of your db. Now you connect to the Access db the same way you would connect to Paradox or any other in Builder.
Just in case you're not familiar with connecting to any DBs in Builder, here's the steps. I would place my table and datasource in a data module. Select New from file menu and choose Data Module. Under the data access tab where all the components are located, drop a table and datasource in the data module. With the focus on your table component, click beside "DatabaseName" in the Object Inspector and you'll get a drop down list. From here, pick the descriptive alias you typed in earlier. Now go down to "TableName" and pick the table from your Access database that you want to work with. Now click on the data source component to give it focus. Where is says "DataSet" in the Object Inspector, choose the name of the table component. Of course, descriptive names for both the table and data source component are recommended for coding purposes. ALso, for every table you wish to use in your program, you must have a separate table and datasource component.
So, there you are. You probably knew all of the stuff about connecting to the DB with the table and datasource. If not, then you may not know how to code or connect other components on your forms to the tables. If this is the case, let me know and I will help. Also, I keep forgetting you are using ver 4.0 and not 5.0, so I hope everything I told you holds true in 4.0. Good luck!!
thanks a million,
I'm am trying it out tonight on a small table to see if i can do it.
I will let you know how it works out