[Mono-list] Mono-0.31 + mySQL 3.2.3 + null pointer
Oswald Campesato
ocampesato@yahoo.com
Sun, 21 Mar 2004 21:58:17 -0800 (PST)
--0-877438523-1079935097=:44319
Content-Type: text/plain; charset=us-ascii
Hello, everyone:
I'm trying to extract data from a mySQL database on Windows XP.
I tried the C# sample code available at the Mono site, which did not
work, and so I tried various other code samples. The code listed
below appears to encounter an error at the following line:
myConnection.Open();
I've been working with C# for less than a week, so I'm not sure if
the obvious has been overlooked. Suggestions welcome....
Cordially,
Oswald
Here's the C# code:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
using System;
using System.Reflection;
using System.Data;
using ByteFX.Data.MySqlClient;
public class test2
{
public static void Main(string[] args)
{
try {
//string myConnectionString = "DSN=test;UID=;PWD=";
string myConnectionString = "DSN=test;UID=root;PWD=root";
MySqlConnection myConnection =
new MySqlConnection(myConnectionString);
string myInsertQuery = "Select * from Simple1";
MySqlCommand myCommand = new MySqlCommand(myInsertQuery);
myCommand.Connection = myConnection;
myConnection.Open();
MySqlDataReader objReader = myCommand.ExecuteReader();
while(objReader.Read())
{
//print results here...
}
}
catch(Exception ex) {
Console.WriteLine(ex.StackTrace);
}
}
}
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Here's the compilation line:
xxxxxxxxxxxxxxxxxxxxxx
mcs /t:winexe test2.cs -lib:C:\Mono-0.29\lib -r System.Data.dll -r ByteFX.Data.dll -r ByteFX.MySqlClient.dll -r ByteFX.MySqlClient.Design.dll -r ICSharpCode.SharpZipLib.dll
Here's the error stack:
xxxxxxxxxxxxxxxxxx
at ByteFX.Data.Common.MultiHostStream.ProcessHosts(String hostList, Int32 port, Int32 connectTimeOut)
at ByteFX.Data.Common.MultiHostStream..ctor(String hostList, Int32 port, Int32 readTimeOut, Int32 connectTimeOut)
at ByteFX.Data.MySqlClient.MySqlStream..ctor(String hostList, Int32 port, Int32 readTimeOut, Int32 connectTimeOut)
at ByteFX.Data.MySqlClient.Driver.Open(MySqlConnectionString settings)
at ByteFX.Data.MySqlClient.MySqlInternalConnection.Open()
at ByteFX.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
at ByteFX.Data.MySqlClient.MySqlPool.GetPooledConnection()
at ByteFX.Data.MySqlClient.MySqlPool.GetConnection()
at ByteFX.Data.MySqlClient.MySqlPoolManager.GetConnection(MySqlConnectionString settings)
at ByteFX.Data.MySqlClient.MySqlConnection.Open()
at test2.Main(String[] args)
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
--0-877438523-1079935097=:44319
Content-Type: text/html; charset=us-ascii
<DIV>Hello, everyone:</DIV>
<DIV> </DIV>
<DIV>I'm trying to extract data from a mySQL database on Windows XP.</DIV>
<DIV>I tried the C# sample code available at the Mono site, which did not</DIV>
<DIV>work, and so I tried various other code samples. The code listed</DIV>
<DIV>below appears to encounter an error at the following line:</DIV>
<DIV> myConnection.Open();<BR> </DIV>
<DIV>I've been working with C# for less than a week, so I'm not sure if</DIV>
<DIV>the obvious has been overlooked. Suggestions welcome....</DIV>
<DIV> </DIV>
<DIV>Cordially,</DIV>
<DIV> </DIV>
<DIV>Oswald</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Here's the C# code:</DIV>
<DIV>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</DIV>
<DIV>using System;<BR>using System.Reflection;<BR>using System.Data;<BR>using ByteFX.Data.MySqlClient;</DIV>
<DIV>public class test2 <BR>{<BR> public static void Main(string[] args)<BR> {<BR> try {<BR> //string myConnectionString = "DSN=test;UID=;PWD="; <BR> string myConnectionString = "DSN=test;UID=root;PWD=root"; <BR> <BR> MySqlConnection myConnection = <BR> new MySqlConnection(myConnectionString);<BR> <BR> string myInsertQuery = "Select * from Simple1";<BR> <BR> MySqlCommand myCommand = new MySqlCommand(myInsertQuery);<BR> <BR> myCommand.Connection = myConnection;<BR> <BR>
myConnection.Open();<BR> <BR> MySqlDataReader objReader = myCommand.ExecuteReader(); <BR> <BR> while(objReader.Read())<BR> {<BR> //print results here...<BR> }<BR> } <BR> catch(Exception ex) {<BR> Console.WriteLine(ex.StackTrace);<BR> }<BR> }<BR>}</DIV>
<DIV>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Here's the compilation line:</DIV>
<DIV>xxxxxxxxxxxxxxxxxxxxxx</DIV>
<DIV>mcs /t:winexe test2.cs -lib:C:\Mono-0.29\lib -r System.Data.dll -r ByteFX.Data.dll -r ByteFX.MySqlClient.dll -r ByteFX.MySqlClient.Design.dll -r ICSharpCode.SharpZipLib.dll</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Here's the error stack:</DIV>
<DIV>xxxxxxxxxxxxxxxxxx</DIV>
<DIV> at ByteFX.Data.Common.MultiHostStream.ProcessHosts(String hostList, Int32 port, Int32 connectTimeOut)<BR> at ByteFX.Data.Common.MultiHostStream..ctor(String hostList, Int32 port, Int32 readTimeOut, Int32 connectTimeOut)<BR> at ByteFX.Data.MySqlClient.MySqlStream..ctor(String hostList, Int32 port, Int32 readTimeOut, Int32 connectTimeOut)<BR> at ByteFX.Data.MySqlClient.Driver.Open(MySqlConnectionString settings)<BR> at ByteFX.Data.MySqlClient.MySqlInternalConnection.Open()<BR> at ByteFX.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()<BR> at ByteFX.Data.MySqlClient.MySqlPool.GetPooledConnection()<BR> at ByteFX.Data.MySqlClient.MySqlPool.GetConnection()<BR> at ByteFX.Data.MySqlClient.MySqlPoolManager.GetConnection(MySqlConnectionString settings)<BR> at ByteFX.Data.MySqlClient.MySqlConnection.Open()<BR> at test2.Main(String[] args)</DIV>
<DIV>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</DIV>
<DIV> </DIV>
<DIV> </DIV><p><font face=arial size=-1>Do you Yahoo!?<br>
<a href="http://taxes.yahoo.com/filing.html"><b>Yahoo! Finance Tax Center</a></b> - File online. File on time.
--0-877438523-1079935097=:44319--