0

I'm trying to create a connection to an Interbase ToGo database, at runtime, in a unit that does not have a form.

MyConnection := TSQLConnection.Create(nil);
strTestPath := TPath.Combine(TPath.GetDocumentsPath, 'ISHMAEL.GDB');
MyConnection.Params.Add('Database=' + strTestPath);
MyConnection.DriverName := 'IBToGo';
MyConnection.Params.Add('User_Name=SYSDBA');
MyConnection.Params.Add('Password=masterkey');
MyConnection.Open();

Everything seems fine as I step through, until I try and open the connection. The open raises an I/O error, saying that database.gdb isn't found. I called the database ISHMAEL, so is something else happening, or is the error message misleading?

Ideally, I'd like to get all of my database calls (and really, most if not all of the business logic) out of the forms and into some data access and business object units, but am having difficulty finding examples.

All of the examples and tutorials I have found focus on dropping controls on a form, and using visual live bindings.

Can this be done inside a non-form unit?

Thanks!

JFish
  • 61
  • 2
  • 5
  • I'd start by removing the '.\' from your `Database` parameter. `TPath.GetDocumentsPath` should contain everything you need to reach the documents folder, so you shouldn't have to prefix it with anything. – Ken White Nov 27 '13 at 18:40
  • Yep. I've been trying all kinds of things, and forgot to pull that .\ out. It still produces the same error though, and it seems like no matter what I put in the database paramater, it's always "database.gdb" that can't be found instead of Ishmael. – JFish Nov 27 '13 at 18:49
  • That would be the default database name from `dbxconnections.ini`: `IBConnection]DriverName=Interbase Database=database.gdb`. Try clearing your parameters first, or adding a new section with configuration info specific to your database. – Ken White Nov 27 '13 at 18:54
  • Thanks Ken. Perhaps it's an indication of deeper problems, but I can't find dbxconnections.ini (or any *.ini files) in my project folders. Starting to wonder if my approach is all wrong... – JFish Nov 27 '13 at 19:29
  • There's no `.ini` extension on non-Windows platforms. See the [TSQLConnection docs](http://docwiki.embarcadero.com/Libraries/XE5/en/Data.SqlExpr.TSQLConnection). (I missed the `mobile` tag.) – Ken White Nov 27 '13 at 19:37

0 Answers0