Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Create new database using DAC...
Wed, Mar 11 2009 12:47 PMPermanent Link

David Loving
ElevateDB 202b9edbdacstd using .NET Data Provider and VS 2008.

I can manually use the ElevateDB Manager (Unicode) to create a new database name, link it to a folder and then open and run a .SQL script to
create all tables, etc.

How does one use the .NET Data Provider set of classes to create a new database name and link it to a folder?

Please forgive if it is available somewhere in the .NET Data Provider docs... I haven't been able to find it.
Wed, Mar 11 2009 6:02 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

David,

<< I can manually use the ElevateDB Manager (Unicode) to create a new
database name, link it to a folder and then open and run a .SQL script to
create all tables, etc.

How does one use the .NET Data Provider set of classes to create a new
database name and link it to a folder? >>

You would use something like this:

private void button1_Click(object sender, EventArgs e)
{
   string cmdString = "CREATE DATABASE MyDatabase PATH 'c:\\myapp\\data'
DESCRIPTION 'My Database'";

   EDBConnection connection = new
EDBConnection("CONFIGPATH=c:\\unicode;UID=Administrator;PWD=EDBDefault;DATABASE=Configuration");

   connection.Open();

   EDBCommand cmd = new EDBCommand(cmdString, connection);

   cmd.ExecuteNonQuery();
}

Notice the use of the Configuration database in the connection string.  Once
you've created the database, you can use the ChangeDatabase method of the
EDBConnection class to switch to the newly-created database.  You can then
run the script against the database to create all of the tables, etc. using
an EDBCommand instance.

Of course, you should take care to Dispose of the EDBCommand and
EDBConnection instances when you're done with them.

--
Tim Young
Elevate Software
www.elevatesoft.com

Thu, Mar 12 2009 11:39 AMPermanent Link

David Loving
Excellent!  Thank you!
Image