More ADO Questions... 
Author Message
 More ADO Questions...

First of all, apologies if this is a duplicate posting, only I haven't seen
my previous posting of this question appear.

Right then, I have my database connection with a .mdb database working
with the ADO components in D5ent. All seems to be fine, but can anyone
tell me how, if it's possible, to create a new table in the connected database,
via the ADO connection.  I have seen other threads on creating tables but
they seemed to be using a different connection method and I was unable
to get them to work for me.

I would appreciate some help with this, and thanks to those who helped
with my other questions.

TIA.

Regards,
Scott



Wed, 18 Jun 1902 08:00:00 GMT
 More ADO Questions...

To create a new table in an already connected
MDB file (database), you have a few choices,
using either VCL components or SQL is what
most of them come down to. You can look up
the VCL stuff for yourself under the ADOExpress
of one of the other ADO providers like DiamondADO.

Personally I prefer to use SQL statements to
create or do other server-oriented tasks (like
mass deletions, etc...) Try creating a  TADOQuery
object and set the SQL statement to read
something like,

create table MyNewTable ( field1 varchar(10), field2 numeric )

obviously substituting whatever table definitions
you need for your specific fields. Note that different
engines will re-map the normal SQL data types
to suit their own purposes.

You should do the setting and execution programatically
but if you must, then you can use the open and close
procedures for the query to perform it's execution.

Normally I'd do something like the following;

Drop a query component on your form (or in the var list
and call it's create method, it's you choice), then assuming
you called it something like TADOQuery1, try;

TADOQuery1.SQL.Clear;
TADOQuery1.SQL.Add( 'create table ( your_table_defn_goes_here )' );
TADOQuery1.ExecSQL;
TADOQuery1.Close;

I'm using DiamondADO. If you're using ADOExpress, some
of the method/procedure names may differ slightly.

HTH

-------------------------------------------------------------------
"If you think you know the answer,
then you don't understand the question !"
-------------------------------------------------------------------


Quote:
> First of all, apologies if this is a duplicate posting, only I haven't
seen
> my previous posting of this question appear.

> Right then, I have my database connection with a .mdb database working
> with the ADO components in D5ent. All seems to be fine, but can anyone
> tell me how, if it's possible, to create a new table in the connected
database,
> via the ADO connection.  I have seen other threads on creating tables but
> they seemed to be using a different connection method and I was unable
> to get them to work for me.

> I would appreciate some help with this, and thanks to those who helped
> with my other questions.

> TIA.

> Regards,
> Scott



Wed, 18 Jun 1902 08:00:00 GMT
 More ADO Questions...

[Snip lots of helpful stuff]

Thanks very much for your help.  I didn't realise SQL could be
used for things other than queries (o;
I've just printed out the entire LocalSQL.hlp and look forward to
some "interesting" reading.  I have been programming for years
but this is the first "grown-up database" type programming I
have ever done, hence all the silly questions.
Thanks again for your help.

Regards,
Scott



Wed, 18 Jun 1902 08:00:00 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. Newbie: ADO question, updating datafields

2. easy ADO question/mlml

3. ADO Question - Please help - How To Keep one connection open

4. ADO question

5. Locking with ADO question

6. ADO Question

7. Newbie ADO Question

8. SQL7, Application Role and ADO Question

9. VB6 & ADO questions

10. XML ASP ADO question

11. 2 small ADO questions

12. Easy Stored Procedure ADO question?


 
Powered by phpBB® Forum Software