MySQL Forums
Forum List  »  Delphi

Creating a Database
Posted by: Henry Martin
Date: May 29, 2006 05:18PM

I have a piece of software which I use for troubleshooting Novell Servers. As all Novell servers come with MySQL. it seemed to be a good idea to put all the info (and it's a lot) into a MySQL Database.

I assumed (and still do until proven otherwise) that I can create a database from within Delphi using SQL. I know I can create an Access one but that isn't what I want to do as I don't want to force people to buy MS-Access.

I wrote an SQL Statement which takes the Hostname, the Username and User Password, and then using a MicroOlap database Object assigned these properties and executed connect := true - No problem

Next I created a simple SQL Statement to Create a Database as shown below. I tested the SQL before I coded it and the syntax seemed OK.

DataMod.dbmySQLServerInfo.Host := edtmySQLHost.Text;
DataMod.dbmySQLServerInfo.UserName := edtmySQLUser.Text;
DataMod.dbmySQLServerInfo.UserPassword := edtmySQLPwd.Text;

DataMod.dbmySQLServerInfo.DatabaseName := '';
DataMod.dbmySQLServerInfo.Connected := True;

{ Better make sure it doesn't exist }
DataMod.MySQLCreate.Close;
DataMod.mySQLCreate.SQL.Clear;
DataMod.mySQLCreate.SQL.Add('DROP DATABASE IF EXISTS novservers');
DataMod.mySQLCreate.ExecSQL;
DataMod.mySQLCreate.SQL.Clear;
DataMod.mySQLCreate.SQL.Add('CREATE DATABASE novservers');
DataMod.mySQLCreate.ExecSQL;
DataMod.mySQLCreate.SQL.Add('CREATE DATABASE novservers');
DataMod.mySQLCreate.ExecSQL;

I have stepped through the code and it connects to mySQL Server and executes to the ExecSQL and I get an error "Database not set". I tried without checking for Exist and get the same result with a simple create.

There must be a way to do this, but I'm lost. Can anyone give me some guidance. It would be much appreciated.

I'm using Delphi 5

Options: ReplyQuote


Subject
Written By
Posted
Creating a Database
May 29, 2006 05:18PM
May 29, 2006 10:41PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.