Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 07-19-2004, 10:17 AM   #1 (permalink)
milena
Registered User
 
Join Date: Jul 2004
Posts: 7
milena is on a distinguished road
MySQLDriverCS and VC++.NET

Hi!
I've installed MySQLDriverCS in order to be able to work with a MySQL database, but I don't know how to use this driver in a C++ console application project.
I know I am supposed to add a reference to MySQLDriverCS.dll in my solution, but I think I don't have the same version of Visual Studio.NET than the person who wrote this :
codenewbie.com/tutorials/1704.html

In fact, I can't "Add Reference" because I don't have this option in my Solution Explorer. Since I don't really know what we do when we add a reference, I'm unable to find another mean to do this. The only thing I succeeded with is adding MySQLDRiverCS.dll as a "solution item". Unfortunatly, it doesn't work because I'm still getting the following error for the line "using MySQLDriverCS;" :

error C2873: 'MySQLDriverCS' : symbol cannot be used in a using-declaration

I have Microsoft .NET Framework 1.0 and Microsoft Development environment 2002 installed and I' using the Academic version of VS.NET.
I hope someone will find out what's wrong with the way I'm trying to use MySQLDriverCS....

Thanks!
Milena
milena is offline   Reply With Quote
Old 07-19-2004, 10:55 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
Here is a screen shot. I'm using Visual Studio Enterprise Edition, .. but I think this should be the same in the standard edition too.

I started a new C++ Console App named: MySQLDriverCS, then I expanded the "References" line on the tree. Right Clicked and chose: Add Reference.

After that, you need to browse to the directory where you installed the driver.

Are you not seeing what is in my screen shot?
Attached Images
File Type: jpg ss1.jpg (35.0 KB, 49 views)
__________________
Mike
sde is offline   Reply With Quote
Old 07-19-2004, 11:33 AM   #3 (permalink)
milena
Registered User
 
Join Date: Jul 2004
Posts: 7
milena is on a distinguished road
Thanks for the advice sde, but the problem is that I don't have any "References" folder in the solution explorer when I create a new projet. I've tried many different kinds of projects, but I only have "Sources Files", "Header Files" and "Ressources Files" folders in the "solution explorer"

If I right click on my project, I don't have the option "Add references", I can only "Add Web reference" or "Add..." (wich has the following options : "Add new item", "Add existing item", "New Folder", "Add Class", "Add Ressource")

What's wrong with my version of Visual Studio.NET???

Thanks!
milena is offline   Reply With Quote
Old 07-19-2004, 02:04 PM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
sounds to me like it may be a student edition thing. i am waiting to see if someone else knows .. i'll post if i find anything.
__________________
Mike
sde is offline   Reply With Quote
Old 07-20-2004, 06:31 AM   #5 (permalink)
milena
Registered User
 
Join Date: Jul 2004
Posts: 7
milena is on a distinguished road
Hi! I've searched more on Visual Studio.NET and it looks like I can't connect to a remote source with this edition. I will buy a Pro edition of VS.NET...
Fore those interested, you can find more information on the differences between the standard and professional editions of VS.NET at the following address:
http://www.sitepoint.com/forums/showthread.php?t=131019
milena is offline   Reply With Quote
Old 07-20-2004, 06:34 AM   #6 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
try this:
compile your empty project so you get the "Debug" directory.

then copy MySQLDriverCS.dll to your debug directory.

now add the following code to your project:
Code:
#using <MySQLDriverCS.dll>
this should compile, .. i'm not sure how to re-write my c# code in c++.net though.

let me know if this helps.
__________________
Mike
sde is offline   Reply With Quote
Old 07-21-2004, 07:58 AM   #7 (permalink)
milena
Registered User
 
Join Date: Jul 2004
Posts: 7
milena is on a distinguished road
I bought a new version of Visual Studio : Visual Studio.NET 2003 Academic Version (wich is the Pro version + student tools). Strangely, it is really different from my 2002 Academic version. I've reinstalled MySQLDriverCS after installing VS.NET 2003.
I've added a reference to MySQLDriverCS in my project and added the path to MySQLDriverCS.dll in the project properties, under the C++/General tag).
Then, I've tried using the dll the same way as I'm actually using other dlls:

Code:
#import "MySQLDriverCS.dll"
But I got the following error when trying to build the project:

fatal error C1083: Cannot open type library file: 'c:\program files\mysqldrivercs\dll\mysqldrivercs.dll': Erreur lors du chargement de la bibliothèque/DLL du type.
(sorry for the French part. I don't know the exact translation, but it's something like:"Error while loading library/of DLL type" )

Then, I've tried to use the library the way sde suggested me (even if I was really sceptic about the syntax ). It compiles, but there are a lot of warnings. Then if I try the following code:
Code:
		MySQLConnection con;
I get this error:
error C2065: 'MySQLConnection' : undeclared identifier

So, I'm unable to use the library this way too.

Now, I just don't know what else to try...any suggestions?
milena is offline   Reply With Quote
Old 07-21-2004, 09:34 AM   #8 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
Code:
using namespace MySQLDriverCS;
__________________
Mike
sde is offline   Reply With Quote
Old 07-21-2004, 10:35 AM   #9 (permalink)
milena
Registered User
 
Join Date: Jul 2004
Posts: 7
milena is on a distinguished road
Thanks sde, that's what I finally found too , but i also had to add references to System.Data.dll and mscorlib.dll in my project.

Unfortunatly, Im still having trouble with MySQLDriverCS while using the following code:

Code:
MySQLDriverCS::MySQLConnection *con;
MySQLDriverCS::MySQLConnectionString *connectionString = new MySQLConnectionString(HOST, DATABASE, LOGIN, PASSWORD);//parameters values are defined at the beginning of my project
con = new MySQLConnection( connectionString->AsString);
con->Open();
con->Close();
The project compiles, but there's an exception while executing the code (when trying to open connection):

An unhandled exception of type 'System.DllNotFoundException' occurred in mysqldrivercs.dll

Additional information: Unable to load DLL(libmySQL.dll).


Then, I tried to add this dll as a reference (even if I don't know if it's what I should do), but an error occured:

AddReference: Error adding reference to the project


What am I doing wrong?
Is there any C++ code sample using MySQLDriverCS?

Thanks again!
Milena
milena is offline   Reply With Quote
Old 07-21-2004, 11:26 AM   #10 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
i don't know c++ that well. c# makes life much easier with .net
__________________
Mike
sde is offline   Reply With Quote
Old 07-21-2004, 11:56 AM   #11 (permalink)
milena
Registered User
 
Join Date: Jul 2004
Posts: 7
milena is on a distinguished road
This is probably easier to use MysqlDriverCS with C# because there are a lot of examples. The problem is that my application doesn't only have to communicate with Mysql, but also with an accountancy software (via COM). The support for this software is mostly done with C++ (and VB) and Visual Studio. That's the only reason why I am using C++.
milena is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 03:58 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting