[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>&nbsp;</DIV>
<DIV>I'm trying to extract data from a mySQL database&nbsp;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&nbsp;code samples.&nbsp; The&nbsp;code listed</DIV>
<DIV>below appears to encounter an error at the following line:</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myConnection.Open();<BR>&nbsp;</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.&nbsp; Suggestions welcome....</DIV>
<DIV>&nbsp;</DIV>
<DIV>Cordially,</DIV>
<DIV>&nbsp;</DIV>
<DIV>Oswald</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</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>&nbsp;&nbsp; public static void Main(string[] args)<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try {<BR>&nbsp;&nbsp;&nbsp;&nbsp; //string myConnectionString = "DSN=test;UID=;PWD="; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string myConnectionString = "DSN=test;UID=root;PWD=root"; <BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MySqlConnection myConnection = <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new MySqlConnection(myConnectionString);<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string myInsertQuery = "Select * from Simple1";<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MySqlCommand myCommand = new MySqlCommand(myInsertQuery);<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myCommand.Connection = myConnection;<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 myConnection.Open();<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MySqlDataReader objReader = myCommand.ExecuteReader(); <BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while(objReader.Read())<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //print results here...<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp;&nbsp; catch(Exception ex) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(ex.StackTrace);<BR>&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp; }<BR>}</DIV>
<DIV>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>Here's the compilation line:</DIV>
<DIV>xxxxxxxxxxxxxxxxxxxxxx</DIV>
<DIV>mcs /t:winexe&nbsp;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>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>Here's the error stack:</DIV>
<DIV>xxxxxxxxxxxxxxxxxx</DIV>
<DIV>&nbsp;&nbsp; at ByteFX.Data.Common.MultiHostStream.ProcessHosts(String hostList, Int32 port, Int32 connectTimeOut)<BR>&nbsp;&nbsp; at ByteFX.Data.Common.MultiHostStream..ctor(String hostList, Int32 port, Int32 readTimeOut, Int32 connectTimeOut)<BR>&nbsp;&nbsp; at ByteFX.Data.MySqlClient.MySqlStream..ctor(String hostList, Int32 port, Int32 readTimeOut, Int32 connectTimeOut)<BR>&nbsp;&nbsp; at ByteFX.Data.MySqlClient.Driver.Open(MySqlConnectionString settings)<BR>&nbsp;&nbsp; at ByteFX.Data.MySqlClient.MySqlInternalConnection.Open()<BR>&nbsp;&nbsp; at ByteFX.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()<BR>&nbsp;&nbsp; at ByteFX.Data.MySqlClient.MySqlPool.GetPooledConnection()<BR>&nbsp;&nbsp; at ByteFX.Data.MySqlClient.MySqlPool.GetConnection()<BR>&nbsp;&nbsp; at ByteFX.Data.MySqlClient.MySqlPoolManager.GetConnection(MySqlConnectionString settings)<BR>&nbsp;&nbsp; at ByteFX.Data.MySqlClient.MySqlConnection.Open()<BR>&nbsp;&nbsp; at test2.Main(String[] args)</DIV>
<DIV>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</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--