473,378 Members | 1,438 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

MySQL & Datagrid using C# - getting compile error

Trying to connect to MySQL db on localhost, and populate datagrid from a
dataset using code inline method.

Getting the following compile error:

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

I downloaded the add on for connecting to MySQL using ADO.NET and installed
it, but am still getting this error. Anybody ever run into this before?
My Code:
<%@ Page Language="C#" %>
<%@ import namespace="CoreLab.MySql" %>

<script runat="server">

private void Page_Load(object sender, System.EventArgs e)
{

// create a connection
MySqlConnection oMySqlConn = new MySqlConnection();
oMySqlConn.ConnectionString = "User ID=myuserid;" +
"Password=mypassword;" +
"Host=localhost;" +
"Port=3306;" +
"Database=mydatabase;" +
"Direct=true;" +
"Protocol=TCP;" +
"Compress=false;" +
"Pooling=true;" +
"Min Pool Size=0;" +
"Max Pool Size=100;" +
"Connection Lifetime=0";
//open connection
oMySqlConn.Open();

// create a data adapter
string querystring = "select * from <database>.<table name> where
date='2004-06-01'"
OleDbDataAdapter da = new OleDbDataAdapter(querystring,
myConnection);

// create a new dataset
DataSet ds = new DataSet();

// fill dataset
da.Fill(ds, "GuidingErr");

// Attach DataSet to DataGrid
DataGrid1.DataSource = ds;
DataGrid1.DataBind();

oMySqlConn.Close();
}

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:DataGrid id="DataGrid1" runat="server"></asp:DataGrid>
</form>
</body>
</html>
Nov 18 '05 #1
6 3164
Hello,

Try to add this row at the beginning of your code:

<%@ Register TagPrefix="cr" Namespace="CoreLab.MySql"
Assembly="CoreLab.MySql, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=09af7300eec23701" %>
Nov 18 '05 #2
I had to make some other changes to my code to get this to work, so I'm
posting my new code in case anybody else needs this info in the future and
comes across this thread.

Thanks again for your help Vladimir!

My Code:

<%@ Page Language="C#" Debug="true" %>
<%@ Register TagPrefix="cr" Namespace="CoreLab.MySql"
Assembly="CoreLab.MySql, Version=2.40.1.0, Culture=neutral,
PublicKeyToken=09af7300eec23701" %>
<%@ import Namespace="CoreLab.MySql" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script runat="server">

private void Page_Load(object sender, System.EventArgs e)
{

// create a connection
MySqlConnection oMySqlConn = new MySqlConnection();
oMySqlConn.ConnectionString = "User ID=<user id>;" +
"Password=<password>;" +
"Host=localhost;" +
"Database=<db name>;" +
"Direct=true;" +
"Protocol=TCP;" +
"Compress=false;";
string querystring = "select fields from table";

MySqlCommand mySqlCommand = new
CoreLab.MySql.MySqlCommand(querystring);

MySqlDataAdapter da = new CoreLab.MySql.MySqlDataAdapter();

DataSet ds = new DataSet();

mySqlCommand.Connection = oMySqlConn;

da.SelectCommand = mySqlCommand;

oMySqlConn.Open();
// fill dataset
da.Fill(ds, "Results");

// Attach DataSet to DataGrid
DataGrid1.DataSource = ds;
DataGrid1.DataBind();

oMySqlConn.Close();
}

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:DataGrid id="DataGrid1" runat="server">
<HeaderStyle font-bold="True" forecolor="White"
backcolor="Gray"></HeaderStyle>
<AlternatingItemStyle
backcolor="LightGray"></AlternatingItemStyle>
</asp:DataGrid>
</form>
</body>
</html>

"Vladimir Zheleznyak" <ik**@crlab.com> wrote in message
news:34**************************@posting.google.c om...
Hello,

Try to add this row at the beginning of your code:

<%@ Register TagPrefix="cr" Namespace="CoreLab.MySql"
Assembly="CoreLab.MySql, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=09af7300eec23701" %>

Nov 18 '05 #3
Note that the version value in my Register directive differs from Vladimir's
example. Be sure that you check your version information and put the right
value in there or the compiler won't like it.

-Erik
"Erik H." <er*********@wwireless.com> wrote in message
news:#D**************@TK2MSFTNGP11.phx.gbl...
I had to make some other changes to my code to get this to work, so I'm
posting my new code in case anybody else needs this info in the future and
comes across this thread.

Thanks again for your help Vladimir!

My Code:

<%@ Page Language="C#" Debug="true" %>
<%@ Register TagPrefix="cr" Namespace="CoreLab.MySql"
Assembly="CoreLab.MySql, Version=2.40.1.0, Culture=neutral,
PublicKeyToken=09af7300eec23701" %>
<%@ import Namespace="CoreLab.MySql" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script runat="server">

private void Page_Load(object sender, System.EventArgs e)
{

// create a connection
MySqlConnection oMySqlConn = new MySqlConnection();
oMySqlConn.ConnectionString = "User ID=<user id>;" +
"Password=<password>;" +
"Host=localhost;" +
"Database=<db name>;" +
"Direct=true;" +
"Protocol=TCP;" +
"Compress=false;";
string querystring = "select fields from table";

MySqlCommand mySqlCommand = new
CoreLab.MySql.MySqlCommand(querystring);

MySqlDataAdapter da = new CoreLab.MySql.MySqlDataAdapter();

DataSet ds = new DataSet();

mySqlCommand.Connection = oMySqlConn;

da.SelectCommand = mySqlCommand;

oMySqlConn.Open();
// fill dataset
da.Fill(ds, "Results");

// Attach DataSet to DataGrid
DataGrid1.DataSource = ds;
DataGrid1.DataBind();

oMySqlConn.Close();
}

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:DataGrid id="DataGrid1" runat="server">
<HeaderStyle font-bold="True" forecolor="White"
backcolor="Gray"></HeaderStyle>
<AlternatingItemStyle
backcolor="LightGray"></AlternatingItemStyle>
</asp:DataGrid>
</form>
</body>
</html>

"Vladimir Zheleznyak" <ik**@crlab.com> wrote in message
news:34**************************@posting.google.c om...
Hello,

Try to add this row at the beginning of your code:

<%@ Register TagPrefix="cr" Namespace="CoreLab.MySql"
Assembly="CoreLab.MySql, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=09af7300eec23701" %>


Nov 18 '05 #4
I had to make some other changes to my code to get this to work, so I'm
posting my new code in case anybody else needs this info in the future and
comes across this thread.

Thanks again for your help Vladimir!

My Code:

<%@ Page Language="C#" Debug="true" %>
<%@ Register TagPrefix="cr" Namespace="CoreLab.MySql"
Assembly="CoreLab.MySql, Version=2.40.1.0, Culture=neutral,
PublicKeyToken=09af7300eec23701" %>
<%@ import Namespace="CoreLab.MySql" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script runat="server">

private void Page_Load(object sender, System.EventArgs e)
{

// create a connection
MySqlConnection oMySqlConn = new MySqlConnection();
oMySqlConn.ConnectionString = "User ID=<user id>;" +
"Password=<password>;" +
"Host=localhost;" +
"Database=<db name>;" +
"Direct=true;" +
"Protocol=TCP;" +
"Compress=false;";
string querystring = "select fields from table";

MySqlCommand mySqlCommand = new
CoreLab.MySql.MySqlCommand(querystring);

MySqlDataAdapter da = new CoreLab.MySql.MySqlDataAdapter();

DataSet ds = new DataSet();

mySqlCommand.Connection = oMySqlConn;

da.SelectCommand = mySqlCommand;

oMySqlConn.Open();
// fill dataset
da.Fill(ds, "Results");

// Attach DataSet to DataGrid
DataGrid1.DataSource = ds;
DataGrid1.DataBind();

oMySqlConn.Close();
}

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:DataGrid id="DataGrid1" runat="server">
<HeaderStyle font-bold="True" forecolor="White"
backcolor="Gray"></HeaderStyle>
<AlternatingItemStyle
backcolor="LightGray"></AlternatingItemStyle>
</asp:DataGrid>
</form>
</body>
</html>

"Vladimir Zheleznyak" <ik**@crlab.com> wrote in message
news:34**************************@posting.google.c om...
Hello,

Try to add this row at the beginning of your code:

<%@ Register TagPrefix="cr" Namespace="CoreLab.MySql"
Assembly="CoreLab.MySql, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=09af7300eec23701" %>

Nov 18 '05 #5
Note that the version value in my Register directive differs from Vladimir's
example. Be sure that you check your version information and put the right
value in there or the compiler won't like it.

-Erik
"Erik H." <er*********@wwireless.com> wrote in message
news:#D**************@TK2MSFTNGP11.phx.gbl...
I had to make some other changes to my code to get this to work, so I'm
posting my new code in case anybody else needs this info in the future and
comes across this thread.

Thanks again for your help Vladimir!

My Code:

<%@ Page Language="C#" Debug="true" %>
<%@ Register TagPrefix="cr" Namespace="CoreLab.MySql"
Assembly="CoreLab.MySql, Version=2.40.1.0, Culture=neutral,
PublicKeyToken=09af7300eec23701" %>
<%@ import Namespace="CoreLab.MySql" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script runat="server">

private void Page_Load(object sender, System.EventArgs e)
{

// create a connection
MySqlConnection oMySqlConn = new MySqlConnection();
oMySqlConn.ConnectionString = "User ID=<user id>;" +
"Password=<password>;" +
"Host=localhost;" +
"Database=<db name>;" +
"Direct=true;" +
"Protocol=TCP;" +
"Compress=false;";
string querystring = "select fields from table";

MySqlCommand mySqlCommand = new
CoreLab.MySql.MySqlCommand(querystring);

MySqlDataAdapter da = new CoreLab.MySql.MySqlDataAdapter();

DataSet ds = new DataSet();

mySqlCommand.Connection = oMySqlConn;

da.SelectCommand = mySqlCommand;

oMySqlConn.Open();
// fill dataset
da.Fill(ds, "Results");

// Attach DataSet to DataGrid
DataGrid1.DataSource = ds;
DataGrid1.DataBind();

oMySqlConn.Close();
}

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:DataGrid id="DataGrid1" runat="server">
<HeaderStyle font-bold="True" forecolor="White"
backcolor="Gray"></HeaderStyle>
<AlternatingItemStyle
backcolor="LightGray"></AlternatingItemStyle>
</asp:DataGrid>
</form>
</body>
</html>

"Vladimir Zheleznyak" <ik**@crlab.com> wrote in message
news:34**************************@posting.google.c om...
Hello,

Try to add this row at the beginning of your code:

<%@ Register TagPrefix="cr" Namespace="CoreLab.MySql"
Assembly="CoreLab.MySql, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=09af7300eec23701" %>


Nov 18 '05 #6
I am having a similar problem. My code works fine for VB.net but gives
the error - "namespace name corelab not found" in C# code. I tried
using your code - added this at top of the page-

<%@ Register TagPrefix="cr" Namespace="CoreLab.MySql"
<BR>Assembly="CoreLab.MySql, Version=2.70.1.0, Culture=neutral,

<BR>PublicKeyToken=09af7300eec23701" %>

with correct version no. Still when I use using CoreLab.MySql; in my
.cs page, it throws error. Any idea?

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Bill Eldridge | last post by:
I'm trying to grab a document off the Web and toss it into a MySQL database, but I keep running into the various encoding problems with Unicode (that aren't a problem for me with GB2312, BIG 5,...
0
by: Donald Tyler | last post by:
Then the only way you can do it that I can think of is to write a PHP script to do basically what PHPMyAdmin is trying to do but without the LOCAL in there. However to do that you would need to...
0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
2
by: ME | last post by:
I am getting: "ERROR SQLBindParameter not used for all parameters" when attempting to run the following code: Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As...
0
by: George R. Kasica | last post by:
Hello: Trying to upgrade from MySQL 3.23.40 to 4.1.16 and am having no luck getting the sources compiled. If you need further information or output please ask, I would be happy to provide it,...
1
by: gordon.dtr | last post by:
Hi, Has anyone had this problem ? I am using MySQL ODBC 3.51 Driver, with MS Access 2003 and MySQL 4.1.11 standard log. I created my tables in MS Access, then exported them via ODBC to an...
2
by: Norm | last post by:
I'm fairly new to this so please bear with me. I installed MySQL on my local machine and created a database and table. I created a User DSN and a System DSN and they tested ok. Here's my .net...
1
George Lft
by: George Lft | last post by:
ok, first of all, i built my register page using dreamweaver tool which the codes haven been out of control. Now i'm thinking that turning over everything - by using this another set of codes. And...
2
by: ree321 | last post by:
I tried moving an ASP.net project form 1.1 to 2.0. But I am having problems with getting the OnItemDataBound function to run for a datagrid, in 2.0. It only gets called up if AutoGenerateColumns...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.