Data connection in plugin failing


#1

In my new plugin, I have a form that loads a table from an Access database and displays it in a grid. This works fine in a prototype exe that is NOT a Rhino plugin. However, when I execute the same form in a Rhino plugin, it errors out.

The data connection (which tests successfully in the IDE while creating the connection) is
"C:\Visual Studio 2013\Projects\Winforms\Cabinet Labels 2014\Cabinet Labels 2014\bin\jobrpt.mdb"

The connection string is "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=“C:\Visual Studio 2013\Projects\Winforms\Cabinet Labels 2014\Cabinet Labels 2014\bin\jobrpt.mdb”

The error I get when executing the plugin is
"Could not find file ‘C:\Program Files (x86)\Rhinoceros 5.0\System\jobrpt.mdb’."

I have the IDE set to Debug32 and Any CPU.

Any idea why the plugin is looking for the file in the Rhino system folder?


#2

I might have found a hint. In the “app.config” file, the connection string is

        connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\jobrpt.mdb"

Apparently there is an alias to the Rhino System folder and it is named |DataDirectory|.

Is there any way to change this alias to point at a folder under the app (Appdir\app_data, for instance)?


(Menno Deij - van Rijswijk) #3

AppDomain.CurrentDomain.SetData("DataDirectory", "C:\myDB");

Google for connectionstring + datadirectory : second link will tell you.


#4

Thanks again.