attachDatabase method

IAttachment attachDatabase(
  1. IStatus status,
  2. String fileName, [
  3. int dpbLength = 0,
  4. Pointer<Uint8>? dpb,
])

Attach to an existing database. Provide an earlier obtained IStatus interface as a status indicator, database file/alias name, and optional database parameter buffer. Use an instance of IXpbBuilder to allocate and populate the buffer with all required connection parameters (like user name and password).

Implementation

IAttachment attachDatabase(IStatus status, String fileName,
    [int dpbLength = 0, Pointer<Uint8>? dpb]) {
  final fileNameUtf = fileName.toNativeUtf8(allocator: mem);
  try {
    dpb ??= nullptr;
    final res =
        _attachDatabase(self, status.self, fileNameUtf, dpbLength, dpb);
    status.checkStatus();
    return IAttachment(res);
  } finally {
    mem.free(fileNameUtf);
  }
}