Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

trying to use MySql.Data.MySqlClient on aspx page

trying to use MySql.Data.MySqlClient on aspx page

trying to use MySql.Data.MySqlClient on aspx page

I've got a MySQL database running on my laptop and I want to connect to it via some C# scripting.

I have an aspx page that has this at the top:


<%@ Page Language="C#" %>

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="MySql.Data.MySqlClient" %>


<script runat="server">

void Page_Load(object sender, System.EventArgs e)
	MySql.Data.MySqlClient.MySqlConnection con = new MySql.Data.MySqlClient.MySqlConnection();


But I get an error when I try to open this page:


Compiler Error Message: CS0246: The type or namespace name 'MySql' could not be found (are you missing a using directive or an assembly reference?)

Source Error:


Line 2:  
Line 3:  <%@ Import Namespace="System.Data" %>
Line 4:  <%@ Import Namespace="MySql.Data.MySqlClient" %>
Line 5:  
Line 6:  <html> 

I'm assuming that if I have MySQL running on my machine, I have the MySql.Data.MySqlClient library. If so, I can I get my aspx page to access it. If not, how do I get it (and then use it)?
Replies continue below

Recommended for you

RE: trying to use MySql.Data.MySqlClient on aspx page

did you reference the MySql library in your project? If you are not using Visual Studio to create a project, is the library in the GAC (Global Assembly Cache) (%windir%\assembly)? Or somewhere in your site folder?

RE: trying to use MySql.Data.MySqlClient on aspx page

I added MySql.Data.dll to wwwroot/bin/ and it worked.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close