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.

Reply via email to