[Mono-list] ByteFx.Data.MySQLClient.MySQLConnection - connection refused - mysql 4.0.13-2
Maurizio Colucci
seguso.forever@tin.it
Tue, 24 Jun 2003 17:32:37 +0200
On Tuesday 24 June 2003 00:54, Marco Canini wrote:
> On Mon, 2003-06-23 at 23:57, Maurizio Colucci wrote:
> > Hello,
>
> Hi
>
> > I am writing a small ASP.NET site for an exam. I am using with xsp
> > from cvs.
> >
> > Everything so far seems to work fine... session management, asp:label,
> > asp:textbox, asp:listbox.
> >
> > Now I just need to add some mysql query. :-)
> >
> > Is it possible with xsp, or must I install apache 2? :-(
>
> Well, there's no relation between mysql, xsp, apache 2: so no you can
> stay with xsp.
> What you need to use is ADO.NET (http://go-mono.org/ado-net.html).
>
> > Some quick starter/examples/pointers-to-existing-docs?
>
> Check the page on mysqlnet provider for a brief example on how to use
> ado.net to access data,
Thanks Marco, that was helpful. Unfortunately the sample at
http://www.go-mono.com/mysql.html
doesn't work, and the error message is too vague (connection refused).
using System;
using System.Data;
using ByteFX.Data.MySQLClient;
public class Test
{
public static void Main(string[] args)
{
string connectionString =
"Server=localhost;" +
"Database=test;" +
"User ID=myuserid;" +
"Password=mypassword;";
IDbConnection dbcon;
dbcon = new MySQLConnection(connectionString);
dbcon.Open();
the last line gives the following error:
Unhandled Exception: System.Net.Sockets.SocketException: Connection refused
in (unmanaged) /usr/lib/libmono.so.0(mono_raise_exception+0x20) [0x400df3cb]
in (unmanaged) /usr/lib/libmono.so.0 [0x400f924e]
in <0x00059> 00 System.Net.Sockets.Socket:Connect (System.Net.EndPoint)
in <0x000c2> 00 ByteFX.Data.MySQLClient.Driver:CreateSocketStream (string,int)
in <0x0002d> 00 ByteFX.Data.MySQLClient.Driver:Open (string,int,string,string,bool)
in <0x00138> 00 ByteFX.Data.MySQLClient.MySQLConnection:Open ()
in <0x00083> 00 .Test:Main (string[])
I am running mysql-server from debian sid. It is version
4.0.13-2. Might that be the reason? :-(( Please tell me it isn't...
Trying to solve that, I looked into
mcs/class/ByteFX.Data/mysqlclient/Connection.cs, and I saw that the
connection string is different:
public MySQLConnection()
{
ConnectionString = "data source=localhost;user id=root;pwd=;database=mysql";
}
So I replaced the connection string with that format, but I get the same error.
What can I do?
Thanks again.
PS: of course I have started the mysql daemon and the connection string is ok.
Maurizio