Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all articles
Browse latest Browse all 7260

Attaching Database OLEDB in MDL-Code

$
0
0

Hi Everyone,

I am trying to write an MDL that creates and attaches certain Attributes to new created graphic Elements into an Access MDB-Database. Therefore I want to make sure, before the creation of new Elements starts, that the correct Database is attached. To have an overview, that the correct MDB is attached to the DGN-file there are the following 3 files with same Name created, before the MDL starts:

- <filename>.dgn  (DGN-file)

- <filename>.mdb  (Access MDB-Database)

- <filename>.udl  (Universal-Data-Link-file)

Here is a part of the Code, that should do this:

int attachDatabaseUDL
(
void
)
  {
	char dgnDevice[MAXFILENAMELENGTH]="\0";	// DGN-Device
	char dgnPath[MAXFILENAMELENGTH]="\0";	// DGN-Path
	char dgnName[MAXFILENAMELENGTH]="\0";	// DGN-Name (WITHOUT Suffix!)
	char udl_file[MAXFILENAMELENGTH]="\0";	// UDL-Filename
	int ret=0;								// Return-Value

	// Reading Name-parts of actual Design-File
	mdlFile_parseName (tcb->dgnfilenm, dgnDevice, dgnPath, dgnName, NULL);

    // Creation of UDL-Name
    strcpy (udl_file, dgnDevice);
	strcat (udl_file, ":");
	strcat (udl_file, dgnPath);
    strcat (udl_file, dgnName);
    strcat (udl_file, ".udl\0");

    // Attaching Database by use of UDLl-file
	ret=mdlDB_activeDatabase(udl_file);

    // Information about Success
    if (ret==SUCCESS) mdlOutput_status ("DB attached");
	else mdlOutput_status ("ERROR! DB NOT attached!");

	return ret;

  }

When I call this function the first time I opened the DGN-file I get an error-message

"Datenbank-Server nicht aktiv" (= Database-Server is not active)

The same happens if I key-in "DB=<full Path>\<filename>.udl" the first time. If I choose via menu "Create Database-Connection" another udl-file, detach the database afterwards and call this function again (or repeat the mentioned key-in), than it works.

So my question is, with which function can make the database-server active, so that the function works, or is there any other reason for this behaviour?

Many thanks for your help,

Ines Wieland


Viewing all articles
Browse latest Browse all 7260

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>