Page 1 of 1

create database for mssql

Posted: 16.02.2007, 23:51
by CharlesMcAllister
Please help!
I found it easy to connect TZConnection to a non-existent firebird database by specifying the 'CREATE DATABASE' sql in the TZConnection.Properties property.

However, how is this done with MSSQL 2005? (specifically i'm testing with the express edition).

How do i connect to MSSQL and create the database using ZLib?
Help is greatly appreciated.

Posted: 17.02.2007, 00:13
by CharlesMcAllister
I'm going to try using the ZPlainADO unit and create the database manually...

AConnection := CoConnection.Create;
AConnection.Open(...);
AConnection.Execute('CREATE DATABASE...');
AConnection.Close;

If someone knows a better way let me know. Thanks!

Posted: 18.02.2007, 09:23
by mdaems
Hi Charles,

You can execute this create right from a normal query component, so you don't have to use the ZPlainADO unit directly.
Query.Text:='Create...';
Query.ExecSQL
Or can't you connect to the database with a ZConnection if the database is not present? For mysql it should work this way.

Mark