how do icheck if database exist with mydac ?
how do icheck if database exist with mydac ?
how exactly i can return if database exits or not ? for example if its exist abort and don't do any thing .
			
									
									
						Re: how do icheck if database exist with mydac ?
If you want to define DB existence at the moment of connection, you can use the following code, having previously set the TMyConnection.Database property to the needed value:
If you want to define DB existence after connection to server is established, use the following code:
			
									
									
						Code: Select all
  MyConnection.Database := 'DBName';
  try
    MyConnection.Connect;
  except
    on E: Exception do
      if Pos('Unknown database', E.Message) <> 0 then
        ShowMessage('Database "DBName" does not exist')
      else
        raise;
  end;Code: Select all
  MyQuery.SQL.Text := 'SELECT IF(EXISTS (SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ''DBName''), ''Yes'', ''No'') ';
  MyQuery.Open;
  if MyQuery.Fields[0].AsString = 'No' then
    ShowMessage('Database "DBName" does not exist');Re: how do icheck if database exist with mydac ?
the second statement raise error 
			
									
									
						Code: Select all
WHERE SCHEMA_NAME = '+variablename+'Re: how do icheck if database exist with mydac ?
To solve the problem, please use the following code:
			
									
									
						Code: Select all
WHERE SCHEMA_NAME = ' + QuotedStr(variablename) +'