LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-02-2009, 07:19 AM   #1
BrajZore
Member
 
Registered: Sep 2007
Location: Växjö
Distribution: Slackware
Posts: 50

Rep: Reputation: 15
MySQL Connector/.NET (Mono)


Hi!

I have some trouble to get MySQL work in Mono. I use Ubunut as os.

I have downloaded the connector and copied the mysql.data.dll into the gac-folder.

But when I try to compile this code:

using System;
using System.Data;
using MySql.Data.MySqlClient;

public class Test
{
public static void Main(string[] args)
{
string connectionString =
"Server=localhost;" +
"Database=test;" +
"User ID=myuserid;" +
"Password=mypassword;" +
"Pooling=false";
IDbConnection dbcon;
dbcon = new MySqlConnection(connectionString);
dbcon.Open();
IDbCommand dbcmd = dbcon.CreateCommand();
// requires a table to be created named employee
// with columns firstname and lastname
// such as,
// CREATE TABLE employee (
// firstname varchar(32),
// lastname varchar(32));
string sql =
"SELECT firstname, lastname " +
"FROM employee";
dbcmd.CommandText = sql;
IDataReader reader = dbcmd.ExecuteReader();
while(reader.Read()) {
string FirstName = (string) reader["firstname"];
string LastName = (string) reader["lastname"];
Console.WriteLine("Name: " +
FirstName + " " + LastName);
}
// clean up
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbcon.Close();
dbcon = null;
}
}


This messages appears(In the Mono IDE):
[Task:File=/home/bryan/Skrivbord/Testexample.cs, Line=2, Column=15, Type=Error, Priority=Normal, Description=The type or namespace name `Data' does not exist in the namespace `System'. Are you missing an assembly reference?(CS0234)]

[Task:File=/home/bryan/Skrivbord/Testexample.cs, Line=3, Column=8, Type=Error, Priority=Normal, Description=The type or namespace name `MySql' could not be found. Are you missing a using directive or an assembly reference?(CS0246)]


When I try to compile the file with this line:
gmcs -r:System.dll -r:System.Data.dll -r:MySql.Data.dll /home/bryan/Skrivbord/Testexample.cs

This message appears:
gmcs -r:System.dll -r:System.Data.dll -r:MySql.Data.dll /home/bryan/Skrivbord/Testexample.cs

Can someone help me?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mysql and mysql java connector, connection refused arubin Slackware 3 03-29-2008 01:41 AM
paint-mono (Paint.net for Mono) Installer? caa1980 Linux - Software 0 10-03-2007 10:52 AM
Mono and .NET blizunt7 Linux - Software 1 05-16-2007 04:54 PM
Using Mono for the .NET Framework chalewa4bambu Linux - Software 0 07-04-2004 02:32 PM
MONO .Net Middleware GtkUser Programming 2 12-19-2003 07:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration