.NET 2.0 version and ProviderFactory

.NET 2.0 version and ProviderFactory

Postby adriana » Mon 26 Dec 2005 18:34

How can I create a MySQLDirect provider instance using ADO.NET 2.0 ProviderFactory?

Thanks.
adriana
 
Posts: 3
Joined: Fri 04 Nov 2005 22:01

A litte DBProvider-Tip:

Postby Tie Cie » Tue 27 Dec 2005 08:58

Use this code to reveal all installed DBProviders, notice that currently crlabs.mysql Provider has to be installed on the target System:
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();
      }
    }


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:

Code: Select all
DBProviderFactory DBProvider DbProviderFactories.GetFactory("MySQLDirect.NET Data Provider");


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
Tie Cie
 
Posts: 5
Joined: Thu 22 Dec 2005 19:35

app.config

Postby Tie Cie » Tue 27 Dec 2005 09:01

Add this to your App.Config:
Code: Select all

   
     
   

   
 


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
Tie Cie
 
Posts: 5
Joined: Thu 22 Dec 2005 19:35

Postby Serious » Tue 27 Dec 2005 09:28

To get MySQLDirect .NET Provider Factory in runtime use following code
Code: Select all
DbProviderFactory mySqlDirectProviderFactory = DbProviderFactories.GetFactory("MySQLDirect.NET Data Provider");
DbConnection mySqlConnection = mySqlDirectProviderFactory.CreateConnection();
...

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.
Serious
 

Postby adriana » Tue 27 Dec 2005 18:13

Thanks everyone.

Is there any way to make the driver work with the DataSources window (the 'Add New connection' dialog?)

I tried adding it to machine.config but it did not work.
adriana
 
Posts: 3
Joined: Fri 04 Nov 2005 22:01

Postby Serious » Wed 28 Dec 2005 07:34

This feature is not supported yet.
Serious
 

Meeting

Postby Megan8743 » Mon 02 Jan 2006 18:20

You guys ever thought of a forum-meeting? I think it'll be great to see the faces behind the keyboards. Unless of course you prefer your keyboard over your face.. :D :-)
Megan8743
 
Posts: 1
Joined: Mon 02 Jan 2006 17:50


Return to dotConnect for MySQL