.NET 2.0 version and ProviderFactory
.NET 2.0 version and ProviderFactory
How can I create a MySQLDirect provider instance using ADO.NET 2.0 ProviderFactory?
Thanks.
Thanks.
A litte DBProvider-Tip:
Use this code to reveal all installed DBProviders, notice that currently crlabs.mysql Provider has to be installed on the target System:
This will show you a List of all providers, on of it should be: "MySQLDirect.NET Data Provider". This is the name of the ProviderFctory:
Now you can create all commands, Dataadapters, simply by a
DBProvider.CreateCommand, .. Command.
For more Infos ask google.
On the Target system there has to be crlabs Provider installes by the setup. I am currently researching how to edit the app.config file to add the Provider-data so that you can simply copy the dll to the output dir.
Regards
Thorsten
Code: Select all
class Program
{
static void Main(string[] args)
{
DataTable DT = DbProviderFactories.GetFactoryClasses();
foreach (DataRow DR in DT.Rows)
{
foreach (DataColumn Dc in DT.Columns)
Console.WriteLine(Dc.ColumnName + " " + DR[Dc]);
Console.WriteLine();
}
Console.ReadLine();
}
}
Code: Select all
DBProviderFactory DBProvider DbProviderFactories.GetFactory("MySQLDirect.NET Data Provider");
DBProvider.CreateCommand, .. Command.
For more Infos ask google.
On the Target system there has to be crlabs Provider installes by the setup. I am currently researching how to edit the app.config file to add the Provider-data so that you can simply copy the dll to the output dir.
Regards
Thorsten
app.config
Add this to your App.Config:
This will enable just Copying the dll to the output dir ( eg for Click Once Installs) ..
Compare this with your Version-Number and the PublicKeyToken with your used corelab - dll.
Thorsten
Code: Select all
Compare this with your Version-Number and the PublicKeyToken with your used corelab - dll.
Thorsten
To get MySQLDirect .NET Provider Factory in runtime use following code
Licensing issues
Generate licensing resource file using following command line:
"%ProgramFiles%\Microsoft Visual Studio 8\SDK\v2.0\Bin\lc.exe" /target:ConsoleApplication50.exe /complist:licenses.licx /i:"%ProgramFiles%\CoreLab\MySQLDirect.NET2\CoreLab.MySql.dll"
According to provided license compiler arguments 'ConsoleApplication50.exe' is your target executable name, 'licenses.licx' is a text file which contains following line: "CoreLab.MySql.MySqlConnection, CoreLab.MySql", "%ProgramFiles%\CoreLab\MySQLDirect.NET2\CoreLab.MySql.dll" is path to CoreLab.MySql.dll assembly.
Change these arguments to correct values.
License compiler will generate 'consoleapplication50.exe.licenses' resource file. You should add this file to your project as embedded resource.
Note that if default namespace of your project is not an empty string it must be the same as target assembly name (in this case - 'ConsoleApplication50'). In this case rename 'consoleapplication50.exe.licenses' to 'exe.licenses' before adding it to project.
If default namespace of your project is not set (is empty string) you do not have to rename resource file before adding it to project.
Issue with default namespace and resource name is caused by IDE. It adds default namespace to resource name when building so it becomes invalid.
Code: Select all
DbProviderFactory mySqlDirectProviderFactory = DbProviderFactories.GetFactory("MySQLDirect.NET Data Provider");
DbConnection mySqlConnection = mySqlDirectProviderFactory.CreateConnection();
...
Generate licensing resource file using following command line:
"%ProgramFiles%\Microsoft Visual Studio 8\SDK\v2.0\Bin\lc.exe" /target:ConsoleApplication50.exe /complist:licenses.licx /i:"%ProgramFiles%\CoreLab\MySQLDirect.NET2\CoreLab.MySql.dll"
According to provided license compiler arguments 'ConsoleApplication50.exe' is your target executable name, 'licenses.licx' is a text file which contains following line: "CoreLab.MySql.MySqlConnection, CoreLab.MySql", "%ProgramFiles%\CoreLab\MySQLDirect.NET2\CoreLab.MySql.dll" is path to CoreLab.MySql.dll assembly.
Change these arguments to correct values.
License compiler will generate 'consoleapplication50.exe.licenses' resource file. You should add this file to your project as embedded resource.
Note that if default namespace of your project is not an empty string it must be the same as target assembly name (in this case - 'ConsoleApplication50'). In this case rename 'consoleapplication50.exe.licenses' to 'exe.licenses' before adding it to project.
If default namespace of your project is not set (is empty string) you do not have to rename resource file before adding it to project.
Issue with default namespace and resource name is caused by IDE. It adds default namespace to resource name when building so it becomes invalid.