[Mono-list] cannot connect to mysql server

Carin Cronander carin.cronander at yahoo.se
Mon Jul 21 12:59:41 EDT 2008


Hi,
I actually hope that I will be corrected now :-), but
I only managed to connect to mysql (5.0.51a) (using mono 1.2.6)
with a password-less user...
Simply:
connStr = string.Format("Server=localhost;" + "Database=handtest;User ID={0}", "monouser");

Haven't gotten around to upgrading myself to a newer version
of mono yet...

Best regards,
Carin


--- Den tors 2008-07-17 skrev Star Liu <minxinjianxin at gmail.com>:

> Från: Star Liu <minxinjianxin at gmail.com>
> Ämne: [Mono-list] cannot connect to mysql server
> Till: mono-list at lists.ximian.com
> Datum: torsdag 17 juli 2008 09.35
> Greetings!
> 
> My code builds successfully, but it cannot connect to mysql
> server
> when it runs, i searched in google about the error
> information:
> "Stream is not a valid .resources file"
> very little information about it, and no solution to it. so
> i ask here.
> 
> Here is the code:
> 
> using System;
> using System.IO;
> using System.Xml;
> using System.Data;
> using MySql.Data.MySqlClient;
> 
> 
> namespace StarConsole
> {
> class MainClass
> {
> public static void Main(string[] args)
> {
>    string connectionString
> ="Server=localhost;Database=Star;User
> ID=root;Password=password;Pooling=false";
>   IDbConnection dbcon = new
> MySqlConnection(connectionString);
>   dbcon.Open();
>   IDbCommand dbcmd = dbcon.CreateCommand();
>   string sql ="insert into
> Departments(deptno,deptname)
> values('0004','caohejin');";
>   dbcmd.CommandText = sql;
>    dbcmd.ExecuteNonQuery();
>   reader.Close();
>   reader = null;*/
>   dbcmd.Dispose();
>   dbcmd = null;
>   dbcon.Close();
>   dbcon = null;
> 
> }
> }
> }
> 
> here is the debug information output by monodevelop
> 
> 
> Unhandled Exception:
> System.Reflection.TargetInvocationException:
> Exception has been thrown by the target of an invocation.
> --->
> System.ArgumentException: Stream is not a valid .resources
> file,
> magic=0x6d783f3c
>   at System.Resources.ResourceReader.ReadHeaders ()
> [0x00000]
>   at System.Resources.ResourceReader..ctor
> (System.IO.Stream stream) [0x00000]
>   at System.Resources.ResourceSet..ctor (System.IO.Stream
> stream) [0x00000]
>   at (wrapper managed-to-native)
> System.Reflection.MonoCMethod:InternalInvoke
> (object,object[])
>   at System.Reflection.MonoCMethod.Invoke (System.Object
> obj,
> BindingFlags invokeAttr, System.Reflection.Binder binder,
> System.Object[] parameters,
> System.Globalization.CultureInfo culture)
> [0x00000] --- End of inner exception stack trace ---
> 
>   at System.Reflection.MonoCMethod.Invoke (System.Object
> obj,
> BindingFlags invokeAttr, System.Reflection.Binder binder,
> System.Object[] parameters,
> System.Globalization.CultureInfo culture)
> [0x00000]
>   at System.Reflection.MonoCMethod.Invoke (BindingFlags
> invokeAttr,
> System.Reflection.Binder binder, System.Object[]
> parameters,
> System.Globalization.CultureInfo culture) [0x00000]
>   at System.Activator.CreateInstance (System.Type type,
> BindingFlags
> bindingAttr, System.Reflection.Binder binder,
> System.Object[] args,
> System.Globalization.CultureInfo culture, System.Object[]
> activationAttributes) [0x00000]
>   at System.Activator.CreateInstance (System.Type type,
> System.Object[] args, System.Object[] activationAttributes)
> [0x00000]
>   at System.Activator.CreateInstance (System.Type type,
> System.Object[] args) [0x00000]
>   at
> System.Resources.ResourceManager.InternalGetResourceSet
> (System.Globalization.CultureInfo culture, Boolean
> Createifnotexists,
> Boolean tryParents) [0x00000]
>   at System.Resources.ResourceManager.GetString
> (System.String name,
> System.Globalization.CultureInfo culture) [0x00000]
>   at
> MySql.Data.MySqlClient.Resources.get_PerfMonCategoryName ()
> [0x00000]
>   at MySql.Data.MySqlClient.PerformanceMonitor..ctor
> (MySql.Data.MySqlClient.MySqlConnection connection)
> [0x00000]
>   at MySql.Data.MySqlClient.MySqlConnection.Open ()
> [0x00000]
>   at StarConsole.MainClass.Main (System.String[] args)
> [0x0000d] in
> /root/Life/Mono/StarConsole/Main.cs:31
> 
> any advice? thanks!
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list


      __________________________________________________________
Låna pengar utan säkerhet. Jämför vilkor online hos Kelkoo.
http://www.kelkoo.se/c-100390123-lan-utan-sakerhet.html?partnerId=96915014


More information about the Mono-list mailing list