Well, it occurs to me that if you can basic data from an existing SQL database, 
like the fields, types, indexes, etc., you could use that information in a SQL 
Exec statement which would just recreate those same tables on other SQL 
instances.

I'm not sure how easy it would be to get things like triggers and stored 
procedures, but I don't think it would be hard just to recreate tables...

I don't know of any existing commands or functions for this - I would have to 
do it through manual coding.


From: Emmanuel Lamy 
Sent: Thursday, September 04, 2008 12:30 AM
To: advanced_delphi@yahoogroups.com 
Subject: [advanced_delphi] Re: AttachDatabase method equivalent in Delphi


Hi Sean,

Thanks for your suggestions. But ADOConnection can only connect with 
an existing database. In my case, the database exists on another 
machine, or another instance of the SQL server on the same machine. 
My question was instead about how to re-create the same database 
using the SQL data and log files. I don't have any problem connecting 
with an existing database. But thank you!

Emmanuel

--- In advanced_delphi@yahoogroups.com, Sean Roberts 
<[EMAIL PROTECTED]> wrote:
>
> Emmanuel:
> 
> I don't know what AttachDatabase (from VB) does, but I think 
vietanh1969 is on the right track.
> 
> If you want to attach to a database in a SQL Server instance, using 
ADO is VERY easy.
> 
> It's all about creating a proper connection string in you 
ADOConnection component.
> 
> Here's a sample connection string from one of my apps (which uses 
ADO to connect to a local instance of SQL Server):
> 
> Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security 
Info=False;User ID=XXXX;Data Source=XXXXX;Use Procedure for 
Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=ATC02-
235;Use Encryption for Data=False;Tag with column collation when 
possible=False
> 
> Just put an ADOConnection component down on a form, then double-
click the ConnectionString property, then click the Build button.
> 
> It will guide you through connecting to anything that has an OLE or 
other type of data connector.
> 
> You can attach to full databases; you can connect to individual 
Excel documents - heck, you can connect to pretty much anything.
> 
> (If you try to connect to Active Directory, be warned that unless 
you use a work-around, you can only return 1000 records at a time...)
> 
> Please let me (us all) know if you have other questions about doing 
this.
> 
> Also look at some of the tutorials on http://delphi.about.com/:
> 
> http://delphi.about.com/od/database/a/adodelphi.htmXFX nForce 680i 
LT SLI Socket 775 | Intel Core 2 Duo E6750 OC:1600 FSB @ 3.2 MHz | 2 
x OCZ SLI 1024MB PC6400 DDR2 800MHz| XION 600w PSU | CM Stacker 200 
ATX/BTX Case | EVGA GeForce 8800 GTS 512 | WD SATA 74 GB Raptor 
(boot/system), WD SATA 500 GB (storage) | Windows XP Pro, SP3 | 
Patient and supportive significant other
> 
> 
> 
> To: [EMAIL PROTECTED]: [EMAIL PROTECTED]: Wed, 3 Sep 2008 16:22:53 
+0700Subject: Re: [advanced_delphi] AttachDatabase method equivalent 
in Delphi
> 
> 
> 
> 
> Hi Emmanuel,The question is quite confusing. Can you please explain 
it a bit more in details? With "SQL Server" did you might the 
ADOSQLConnection or SQLConnection (in SQL Express) or whatelse?On 
Wed, 27 Aug 2008 10:14:50 +0700, Emmanuel Lamy <[EMAIL PROTECTED]> wrote:> Hi 
everybody,>> Anyone knows if there is a Delphi method that 
accomplishes the same> action as the VB "AttachDatabase" method that 
the VB programer can use> to "attach" an existing database defined by 
one or several files to a> defined instance of SQL Server? Or better, 
is there an alternative as> to register an external SQL database file 
with another instance of a> SQL Server, or SQL Express? Any hint or 
suggestions welcome. TIA.>> Emmanuel>>-- Using Opera's revolutionary 
e-mail client: http://www.opera.com/mail/ 
> 
> 
> 
> 
> 
> __________________________________________________________
> See how Windows Mobile brings your life together-at home, work, or 
on the go.
> http://clk.atdmt.com/MRT/go/msnnkwxp1020093182mrt/direct/01/
>



 

Reply via email to