"guba" <ad...@coka.co.yu> wrote:
>How can I create Access table?
Next sample creates new Access database (c:/new.md) and
adds new table (MyTable) in this database:
(Some additional try, catch preferable)
void __fastcall TForm1::Button1Click(TObject *Sender)
{
#define adVarWChar 202
#define adInteger 3
Variant Catalog;
Variant Table;
Variant TablesDataBase;
Variant Columns;
if(FileExists("C://New.mdb"))
{
ShowMessage("Database exist");
Application->Terminate();
return;
}
Catalog=Variant::CreateObject("ADOX.Catalog");
Table=Variant::CreateObject("ADOX.Table");
try{
Catalog.Exec(Function("Create") << "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C://New.mdb;");
}
catch(...)
{
//problems - may be database already exist
}
//Creating table
Table.Exec(PropertySet("Name") << "MyTable");
Columns=Table.Exec(PropertyGet("Columns"));
Columns.Exec(Function("Append") << "ItsFirstField" << adVarWChar << 20);
Columns.Exec(Function("Append") << "Next" << adInteger);
//add table in database:
TablesDataBase=Catalog.Exec(PropertyGet("Tables"));
TablesDataBase.Exec(Function("Append") << Table);
TablesDataBase=Unassigned;
Columns=Unassigned;
Table=Unassigned;
Catalog=Unassigned;
}
Vladimir.
Thank you the example, but I cant it run. The BCB 5 show me a few errors.
"Vladimir Afanasyev" <a...@systema.kiev.ua> wrote in message
news:3e808207$1...@newsgroups.borland.com...
Hi,
"guba" <ad...@coka.co.yu> wrote:
>How can I create Access table?
Next sample creates new Access database (c:/new.md) and
adds new table (MyTable) in this database:
(Some additional try, catch preferable)
void __fastcall TForm1::Button1Click(TObject *Sender)
{
#define adVarWChar 202
#define adInteger 3
Variant Catalog;
Variant Table;
Variant TablesDataBase;
Variant Columns;
if(FileExists("C://New.mdb"))
{
ShowMessage("Database exist");
Application->Terminate();
return;
}
Catalog=Variant::CreateObject("ADOX.Catalog");
Table=Variant::CreateObject("ADOX.Table");
try{
Catalog.Exec(Function("Create") << "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C://New.mdb;");
}
catch(...)
{
file://problems - may be database already exist
}
file://Creating table
Table.Exec(PropertySet("Name") << "MyTable");
Columns=Table.Exec(PropertyGet("Columns"));
Columns.Exec(Function("Append") << "ItsFirstField" << adVarWChar << 20);
Columns.Exec(Function("Append") << "Next" << adInteger);
file://add table in database:
"guba" <ad...@coka.co.yu> wrote:
>Helo Vladimir
>
>Thank you the example, but I cant it run. The BCB 5 show me a few errors.
>
>
I compiled that code on BCB5 and had no any error.
May be you send error description?
Vladimir.
Hi,
The error is "Multiple declaration for 'file' "
"guba" <ad...@coka.co.yu> wrote:
>
>
>The error is "Multiple declaration for 'file' "
It sounds funny, there no any such variable...
I recompile code - it's work.
May be in the next month I create application (with various
possibility from ADO) for working with MS Access and put it
in the codecentral.
Vladimir.
Thanks a lot for your help,
Ivo Karindi
"Vladimir Afanasyev" <a...@systema.kiev.ua> wrote in message
news:3e808207$1...@newsgroups.borland.com...
Could it be the "file:" text that OE inserts when you write
a comment starting with a double slash?
file://this is a comment !!!!!!!!!!!!!!
Bye,
Steve.
"Ivo Karindi" <so...@ieslc.com> wrote:
>Are there any sources (books,
>tutorials, etc) on the 'net where I could learn some more of this
>stuff? I am mostly interested in manipulating and retrieving data from
>a MS Access database from a DLL. I got your DB making example working
>wonderfully from my DLL and would like to learn more of this stuff.
You know our main resource - Microsoft site.
The main info:
ADO Programmer's Guide
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/pg_introduction.asp
ADO Code Samples
http://msdn.microsoft.com/library/default.asp?url=/code/list/ado.asp?frame=true
Samples referenced to MSJ/MSDN online.
And search engine on Microsoft site:
http://www.microsoft.com/isapi/CTRedir.asp?type=CT&source=WWW&sPage=Search_Advanced|Search||Advanced%20Search&tPage=http://search.microsoft.com/advanced_search.asp?siteid=us
I suppose next reference will be very usefull for you:
Defining and Retrieving a Database's Schema
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndao/html/daotoadoupdate_topic6.asp
Regards,
Vladimir.
"Steve" <steve_al...@SPAMhotmail.com> wrote in message
news:3e84...@newsgroups.borland.com...
Thank you for explanation so he need only delete all
comments and "file:" before comments. It is browser problem.
I even wanted to send this sample in the attachment
group. But I use browser (because firewall) for access
to newsgroup. No possibility send file in attachment
group in this case.
I hope guba understand now.
Vladimir.
"guba" <ad...@coka.co.yu> wrote:
>When I write "file://anything " , I can't compile the code. Error is
>"Multiple declaration for 'file'"
>But when I write "// file://anything" I can compile the code, but when I
>click on Button1, the error is "The object referenced by the application no
>longer points to a valid object."
>
So zip your project and send it in the
borland.public.attachment for me or directly on my E-mail.
Vladimir.
was:
Catalog.Exec(Function("Create") << "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C://New.mdb;");
should be:
Catalog.Exec(Function("Create") << "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\New.mdb;");
or
Catalog.Exec(Function("Create") << "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:/New.mdb;");
-----
was:
if(FileExists("C://New.mdb"))
Should be -
if(FileExists("C:\\New.mdb"))
or
if(FileExists("C:/New.mdb"))
Vladimir.