Thread View: borland.public.cppbuilder.database.ado
14 messages
14 total messages
Started by poojo hackma
Fri, 11 Nov 2005 16:32
ADO Create Access DB, BCB6
Author: poojo hackma
Date: Fri, 11 Nov 2005 16:32
Date: Fri, 11 Nov 2005 16:32
8 lines
1375 bytes
1375 bytes
In my BCB6 project, I use an Access database, but I don't want to be forced to include an empty Access db file with each PC that will run my executable. (or, what if some goofball deletes the database on his PC?) What I need is a method to check if there is an Access DB present. If not, create the file, open it, and create the tables. Is this possible? Could someone show me a few basic steps with this?
BCB6 Follow-up
Author: poojo hackma
Date: Fri, 11 Nov 2005 17:42
Date: Fri, 11 Nov 2005 17:42
21 lines
1986 bytes
1986 bytes
Follow-up:
I've looked, and I have "Microsoft ADO Ext. 2.8 for DDL and Security
(Version 2.8)" listed among Project->Import Type Library members. The class
names are TTable, TColumn, TIndex, TKey, TGroup, TUser, and TCatalog.
Several posts searching with
http://groups.google.com/group/borland.public.cppbuilder.database.ado/search?group=borland.public.cppbuilder.database.ado&q=create+database&qt_g=1
mention ways to create databases using TCatalog, but do not show any
examples.
I tried:
TCatalog cat; // also tried TCOM_Catalog cat, but that didn't work either.
cat = CoCatalog::Create();
cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\test.mdb");
But that did not work because BCB6 did not know what either TCatalog nor
TCOM_Catalog were, and they were not listed in my Help files. The closest I
got was something called TCOMAdminCatalog, but this does not look like what
I want.
Re: BCB6 Follow-up
Author: Viatcheslav V. Vassiliev
Date: Fri, 11 Nov 2005 20:18
Date: Fri, 11 Nov 2005 20:18
62 lines
2955 bytes
2955 bytes
Import ADOX type library and execute
//strConn is connection string.
Adox_tlb::TCOM_Catalog cat = CoCatalog::Create();
cat->Create(strConn.c_bstr());
or
CatalogPtr cat = CoCatalog::Create();
cat->Create(strConn);
You may also need to add (for C++ Builder 6)
#include <comobj.hpp>
namespace System
{
void __fastcall CheckSafecallResult(HRESULT hr)
{
OleCheck(hr);
}
}
All strings should be declared as WideString, not as AnsiString.
//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"poojo hackma" <poojo.com/mail> �������/�������� � �������� ���������:
news:4374d7fa$1@newsgroups.borland.com...
> Follow-up:
>
> I've looked, and I have "Microsoft ADO Ext. 2.8 for DDL and Security
> (Version 2.8)" listed among Project->Import Type Library members. The
> class names are TTable, TColumn, TIndex, TKey, TGroup, TUser, and
> TCatalog.
>
> Several posts searching with
> http://groups.google.com/group/borland.public.cppbuilder.database.ado/search?group=borland.public.cppbuilder.database.ado&q=create+database&qt_g=1
> mention ways to create databases using TCatalog, but do not show any
> examples.
>
> I tried:
>
> TCatalog cat; // also tried TCOM_Catalog cat, but that didn't work
> either.
> cat = CoCatalog::Create();
> cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\test.mdb");
>
> But that did not work because BCB6 did not know what either TCatalog nor
> TCOM_Catalog were, and they were not listed in my Help files. The closest
> I got was something called TCOMAdminCatalog, but this does not look like
> what I want.
>
Re: BCB6 Follow-up
Author: poojo hackma
Date: Fri, 11 Nov 2005 21:33
Date: Fri, 11 Nov 2005 21:33
16 lines
1454 bytes
1454 bytes
The code below spit out this error:
E2090 Qualifier 'Adox_tlb' is not a class or a namespace name
//---------------------------------------------------------------------------
#include <comobj.hpp>
namespace System
{
void __fastcall CheckSafecallResult(HRESULT hr)
{
OleCheck(hr);
Adox_tlb::TCOM_Catalog cat = CoCatalog::Create();
}
}
//---------------------------------------------------------------------------
Re: BCB6 Follow-up
Author: Viatcheslav V. Vassiliev
Date: Sat, 12 Nov 2005 09:18
Date: Sat, 12 Nov 2005 09:18
35 lines
2112 bytes
2112 bytes
#include "ADOX_tlb.h"
ADOX_tlb.h is from import of "Microsoft ADO Ext. 2.8 for DDL and Security
(Version 2.8)".
//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"poojo hackma" <poojo.com/mail> �������/�������� � �������� ���������:
news:43750df0$1@newsgroups.borland.com...
> The code below spit out this error:
>
> E2090 Qualifier 'Adox_tlb' is not a class or a namespace name
>
> //---------------------------------------------------------------------------
> #include <comobj.hpp>
>
> namespace System
> {
> void __fastcall CheckSafecallResult(HRESULT hr)
> {
> OleCheck(hr);
> Adox_tlb::TCOM_Catalog cat = CoCatalog::Create();
> }
> }
> //---------------------------------------------------------------------------
>
>
>
Re: BCB6 Follow-up
Author: poojo hackma
Date: Mon, 14 Nov 2005 16:19
Date: Mon, 14 Nov 2005 16:19
52 lines
3826 bytes
3826 bytes
Viatcheslav,
In my code listed below, Line 82 is throwing this error:
(this->Create(ConnectString, (VARIANT*)&Connection))
Error: 80040E73(-2147217805) @ C:\Program
Files\Borland\CBuilder6\Imports\ADOX_tlb.h/487
Press [Y]es to terminate, [N]o to continue and [C]ancel to Debug.
I have included the rest of my CREATE TABLE sql in the hopes that you (or
someone) can point out what will go wrong next before I get there. Some of
the column names are reserved words; so do I need to include them in
[bracket]s? Also, the examples I found only listed a type of "Int" and I
needed to distinguish between "Long Integer" and "Double;" so I substituted
"Int" in the code that I found online with those values ("Long Integer" and
"Double"). Am I doomed??? If so, could someone point me in the right
direction?
74: if (FileExists(OpenDialog1->FileName) == false) {
75: OpenDialog1->Execute();
76: }
77: if (FileExists(OpenDialog1->FileName) == false) {
78: TCOM_Catalog cat = CoCatalog::Create();
79: try { // read in the database
80: char createfile[MAXPATH];
81: strcpy(createfile, OpenDialog1->FileName.c_str());
82: cat->Create(WideString(createfile).c_bstr());
83: ADOConnection1->ConnectionString =
84: ConnectionString(OpenDialog1->FileName.c_str());
85: ADOQuery1->SQL->Clear();
86: ADOQuery1->SQL->Add("CREATE TABLE Table1 (");
87: ADOQuery1->SQL->Add(" ID Long Integer Identity Primary Key,");
88: ADOQuery1->SQL->Add(" Desc VarChar(50),");
89: ADOQuery1->SQL->Add(" Len Long Integer, Res Double, Val Double,");
90: ADOQuery1->SQL->Add(" Ofs Double, Min Double, Max Double,");
91: ADOQuery1->SQL->Add(" Unit VarChar(10), Type VarChar(50),");
92: ADOQuery1->SQL->Add(" Sus Long Integer, PGN Long Integer,");
93: ADOQuery1->SQL->Add(" start Long Integer)");
94: ADOQuery1->ExecSQL();
95: ADOQuery1->Close();
96: ComboBox1->Items->Add("Add New");
97: } catch (Exception* ex) {
98: MessageBox(NULL, ex->Message.c_str(), "DB Exception", MB_OK);
99: }
A0: }
I apologize for having to take up so much of your time. Is there somewhere
I can find this information on my own? I'm trying to reduce the amount of
time you are spending with me. I've been trying to read old messages of
yours. One in particular that looks very relevant is located at:
http://groups.google.com/group/borland.public.cppbuilder.database.ado/browse_thread/thread/624e139e318cdbfb/1fbeae2a8f29cce1?lnk=st&q=ADOX_tlb.h&rnum=2&hl=en#1fbeae2a8f29cce1
but it does not seem to tell me how to fix the problem I am having.
Re: BCB6 Follow-up
Author: Viatcheslav V. Vassiliev
Date: Mon, 14 Nov 2005 22:10
Date: Mon, 14 Nov 2005 22:10
101 lines
5329 bytes
5329 bytes
//
// MessageId: DB_E_BADINITSTRING
//
// MessageText:
//
// Format of the initialization string does not conform to the OLE DB
specification.
//
#define DB_E_BADINITSTRING ((HRESULT)0x80040E73L)
> 80: char createfile[MAXPATH];
> 81: strcpy(createfile, OpenDialog1->FileName.c_str());
> 82: cat->Create(WideString(createfile).c_bstr());
Connection string is not just file name. You should build connection string
in form:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\test.mdb"
as you did at beginning. The same is for:
> 83: ADOConnection1->ConnectionString =
> 84: ConnectionString(OpenDialog1->FileName.c_str());
Do not know what ConnectionString() procedure is for, may be it should be
applied when you create database.
Add also
cat.Release();
after creating database.
//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"poojo hackma" <poojo.com/mail> �������/�������� � �������� ���������:
news:4378b969@newsgroups.borland.com...
> Viatcheslav,
>
> In my code listed below, Line 82 is throwing this error:
>
> (this->Create(ConnectString, (VARIANT*)&Connection))
> Error: 80040E73(-2147217805) @ C:\Program
> Files\Borland\CBuilder6\Imports\ADOX_tlb.h/487
> Press [Y]es to terminate, [N]o to continue and [C]ancel to Debug.
>
> I have included the rest of my CREATE TABLE sql in the hopes that you (or
> someone) can point out what will go wrong next before I get there. Some
> of the column names are reserved words; so do I need to include them in
> [bracket]s? Also, the examples I found only listed a type of "Int" and I
> needed to distinguish between "Long Integer" and "Double;" so I
> substituted "Int" in the code that I found online with those values ("Long
> Integer" and "Double"). Am I doomed??? If so, could someone point me in
> the right direction?
>
> 74: if (FileExists(OpenDialog1->FileName) == false) {
> 75: OpenDialog1->Execute();
> 76: }
> 77: if (FileExists(OpenDialog1->FileName) == false) {
> 78: TCOM_Catalog cat = CoCatalog::Create();
> 79: try { // read in the database
> 80: char createfile[MAXPATH];
> 81: strcpy(createfile, OpenDialog1->FileName.c_str());
> 82: cat->Create(WideString(createfile).c_bstr());
> 83: ADOConnection1->ConnectionString =
> 84: ConnectionString(OpenDialog1->FileName.c_str());
> 85: ADOQuery1->SQL->Clear();
> 86: ADOQuery1->SQL->Add("CREATE TABLE Table1 (");
> 87: ADOQuery1->SQL->Add(" ID Long Integer Identity Primary Key,");
> 88: ADOQuery1->SQL->Add(" Desc VarChar(50),");
> 89: ADOQuery1->SQL->Add(" Len Long Integer, Res Double, Val
> Double,");
> 90: ADOQuery1->SQL->Add(" Ofs Double, Min Double, Max Double,");
> 91: ADOQuery1->SQL->Add(" Unit VarChar(10), Type VarChar(50),");
> 92: ADOQuery1->SQL->Add(" Sus Long Integer, PGN Long Integer,");
> 93: ADOQuery1->SQL->Add(" start Long Integer)");
> 94: ADOQuery1->ExecSQL();
> 95: ADOQuery1->Close();
> 96: ComboBox1->Items->Add("Add New");
> 97: } catch (Exception* ex) {
> 98: MessageBox(NULL, ex->Message.c_str(), "DB Exception", MB_OK);
> 99: }
> A0: }
>
> I apologize for having to take up so much of your time. Is there
> somewhere I can find this information on my own? I'm trying to reduce the
> amount of time you are spending with me. I've been trying to read old
> messages of yours. One in particular that looks very relevant is located
> at:
> http://groups.google.com/group/borland.public.cppbuilder.database.ado/browse_thread/thread/624e139e318cdbfb/1fbeae2a8f29cce1?lnk=st&q=ADOX_tlb.h&rnum=2&hl=en#1fbeae2a8f29cce1
> but it does not seem to tell me how to fix the problem I am having.
>
>
Re: BCB6 Follow-up
Author: poojo hackma
Date: Mon, 14 Nov 2005 23:05
Date: Mon, 14 Nov 2005 23:05
37 lines
2511 bytes
2511 bytes
New error message:
HRCHECK:
'this->Create(ConnectString, (VARIANT*)&Connection)':
No such interface supported
@ C:\Program Files\Borland\CBuilder6\Imports\ADOX_tlb.h/487
Press [Y]es to terminate, [N]o to continue and [C]ancel to Debug
This message is also triggered when I attempt to step over the Create()
method, shown in Line 84 below:
74: if (FileExists(OpenDialog1->FileName) == false) {
75: OpenDialog1->Execute();
76: }
77: if (FileExists(OpenDialog1->FileName) == false) {
78: try { // create new database
79: TCOM_Catalog cat = CoCatalog::Create();
80: char cConnector[MAXPATH];
81: strcpy(cConnector, "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=");
82: strcat(cConnector, OpenDialog1->FileName.c_str());
83: cat = CoCatalog::Create();
84: cat->Create((BSTR)cConnector);
85: cat.Release();
86: ADOConnection1->ConnectionString = cConnector;
87:
where:
OpenDialog1->FileName.c_str() =
"C:\\Documents and Settings\\user1\\My Documents\\
My Projects\\Project1\\database1.mdb"
and
cConnector = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Documents and
Settings\\user1\\My Documents\\My Projects\\Project1\\database1.mdb\0\0..."
Also, is "cat" a pointer or a value? How do I know when to use "cat->" and
when to use "cat."?
ADOX_tlb.h: BCB6 Follow-up
Author: poojo hackma
Date: Tue, 15 Nov 2005 17:45
Date: Tue, 15 Nov 2005 17:45
40 lines
2710 bytes
2710 bytes
I've narrowed the problem down to these two issues in the ADOX_tlb.h file:
First, if I use either of these techniques:
cat.Create((BSTR)cConnector, (tagVARIANT*)ADOConnection1);
or
cat->Create((BSTR)cConnector, (tagVARIANT*)ADOConnection1);
...I get a *runtime* error (EAccessViolation) in ADOX_tlb.h from Line 3434:
Line 3431: template <class T> HRESULT __fastcall
Line 3432: TCOM_CatalogT<T>::Create(BSTR ConnectString/*[in]*/, VARIANT*
Connection/*[out,retval]*/)
Line 3433: {
Line 3434: return (*this)->Create(ConnectString, Connection);
Line 3435: }
The EAccessViolation message is: "Access violation at address 77124BA4 in
module 'OLEAUT32.DLL'. Read of address 00133000'."
Next, if I try to use this technique:
cat.Create((BSTR)cConnector);
...I get a *compile time* error in ADOX_tlb.h on Line 3441:
Line 3437: template <class T> VARIANT __fastcall
Line 3438: TCOM_CatalogT<T>::Create(BSTR ConnectString/*[in]*/)
Line 3439: {
Line 3440: VARIANT Connection;
Line 3441: OLECHECK(this->Create(, (VARIANT*)&Connection));
Line 3442: return Connection;
Line 3443: }
The compiler says E2188 Expression syntax.
Does this shed any light on what might be wrong? What else could I provide
to help?
Re: ADOX_tlb.h: BCB6 Follow-up
Author: Viatcheslav V. Vassiliev
Date: Wed, 16 Nov 2005 07:46
Date: Wed, 16 Nov 2005 07:46
56 lines
3284 bytes
3284 bytes
Write support@oledbdirect.com and I will send you simple sample that creates
Access database.
//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"poojo hackma" <poojo.com/mail> �������/�������� � �������� ���������:
news:437a1e95$1@newsgroups.borland.com...
> I've narrowed the problem down to these two issues in the ADOX_tlb.h file:
>
> First, if I use either of these techniques:
>
> cat.Create((BSTR)cConnector, (tagVARIANT*)ADOConnection1);
> or
> cat->Create((BSTR)cConnector, (tagVARIANT*)ADOConnection1);
>
> ...I get a *runtime* error (EAccessViolation) in ADOX_tlb.h from Line
> 3434:
>
> Line 3431: template <class T> HRESULT __fastcall
> Line 3432: TCOM_CatalogT<T>::Create(BSTR ConnectString/*[in]*/, VARIANT*
> Connection/*[out,retval]*/)
> Line 3433: {
> Line 3434: return (*this)->Create(ConnectString, Connection);
> Line 3435: }
>
> The EAccessViolation message is: "Access violation at address 77124BA4 in
> module 'OLEAUT32.DLL'. Read of address 00133000'."
>
>
> Next, if I try to use this technique:
>
> cat.Create((BSTR)cConnector);
>
> ...I get a *compile time* error in ADOX_tlb.h on Line 3441:
>
> Line 3437: template <class T> VARIANT __fastcall
> Line 3438: TCOM_CatalogT<T>::Create(BSTR ConnectString/*[in]*/)
> Line 3439: {
> Line 3440: VARIANT Connection;
> Line 3441: OLECHECK(this->Create(, (VARIANT*)&Connection));
> Line 3442: return Connection;
> Line 3443: }
>
> The compiler says E2188 Expression syntax.
>
>
> Does this shed any light on what might be wrong? What else could I
> provide to help?
>
>
Re: ADOX_tlb.h: BCB6 Follow-up
Author: poojo hackma
Date: Thu, 17 Nov 2005 14:56
Date: Thu, 17 Nov 2005 14:56
12 lines
1711 bytes
1711 bytes
Interesting. Thanks Viatcheslav. Here is where my problem was: I included the ADOX_tlb.h file in my header, but I did not know I needed to include the ADOX_tlb.cpp file in my project. Moreover, I had no idea where that file was located on my machine! I had to do a search to find it in the same folder where the header was (Program Files\Borland\CBuilder6\Imports for my machine). Thanks again!
Re: ADOX_tlb.h: BCB6 Follow-up
Author: MacGwegg
Date: Mon, 02 Jan 2006 04:42
Date: Mon, 02 Jan 2006 04:42
13 lines
1652 bytes
1652 bytes
Referencing the ADOX_tlb.h and the Project->Import Type Library dialog tool in BCB6, when I try to import the ADOX dll, I get the error message "A class name 'TTable' is already installed". How do I get passed this point to get the import files created? Mike McQuaig ========================== On Tue, 15 Nov 2005 11:45:36 -0600, "poojo hackma" <poojo.com/mail> wrote: >I've narrowed the problem down to these two issues in the ADOX_tlb.h file: >
Re: ADOX_tlb.h: BCB6 Follow-up
Author: AlexB
Date: Mon, 02 Jan 2006 07:55
Date: Mon, 02 Jan 2006 07:55
9 lines
1770 bytes
1770 bytes
MacGwegg wrote: > Referencing the ADOX_tlb.h and the Project->Import Type Library dialog > tool in BCB6, when I try to import the ADOX dll, I get the error > message "A class name 'TTable' is already installed". How do I get > passed this point to get the import files created? http://delphi.about.com/od/database/l/aa072401a.htm Alex.
Re: ADOX_tlb.h: BCB6 Follow-up
Author: MacGwegg
Date: Tue, 03 Jan 2006 03:03
Date: Tue, 03 Jan 2006 03:03
19 lines
1987 bytes
1987 bytes
Thanks Alex, That info was what I needed. I will spend some time on that website re-learning what I should know. Mike Mac ====================== On Mon, 02 Jan 2006 13:55:15 +0600, AlexB <b.a.v@inbox.ru> wrote: >MacGwegg wrote: >> Referencing the ADOX_tlb.h and the Project->Import Type Library dialog >> tool in BCB6, when I try to import the ADOX dll, I get the error >> message "A class name 'TTable' is already installed". How do I get >> passed this point to get the import files created? > >http://delphi.about.com/od/database/l/aa072401a.htm > >Alex.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads