Page 1 of 1

.NET 2.0 version and ProviderFactory

Posted: Mon 26 Dec 2005 18:34
by adriana
How can I create a MySQLDirect provider instance using ADO.NET 2.0 ProviderFactory?

Thanks.

A litte DBProvider-Tip:

Posted: Tue 27 Dec 2005 08:58
by Tie Cie
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

app.config

Posted: Tue 27 Dec 2005 09:01
by Tie Cie
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

Posted: Tue 27 Dec 2005 09:28
by Serious
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.

Posted: Tue 27 Dec 2005 18:13
by adriana
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.

Posted: Wed 28 Dec 2005 07:34
by Serious
This feature is not supported yet.

Meeting

Posted: Mon 02 Jan 2006 18:20
by Megan8743
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 :-)