-2

I have programmed a small program with vb.net with mysql. it is working fine . but while closing my application using "End" command. I'm getting this error.

"System.NullReferenceException was unhandled
HResult=-2147467261enter code here Message=Object reference not set to an instance of an object. Source=MySql.Data StackTrace: at MySql.Data.MySqlClient.NativeDriver.FetchDataRow(Int32 statementId, Int32 columns) at MySql.Data.MySqlClient.Driver.FetchDataRow(Int32 statementId, Int32 columns) at MySql.Data.MySqlClient.Driver.SkipDataRow() at MySql.Data.MySqlClient.ResultSet.Close() at MySql.Data.MySqlClient.MySqlDataReader.NextResult() at MySql.Data.MySqlClient.MySqlDataReader.Close() at MySql.Data.MySqlClient.MySqlConnection.Close() at MySql.Data.MySqlClient.MySqlConnection.Dispose(Boolean disposing) at System.ComponentModel.Component.Finalize() InnerException: "

its only appears when while closing my application. please help me. thank you.

Visual Vincent
  • 17,424
  • 5
  • 24
  • 66

2 Answers2

0

It will be less difficult to answer if you put some of your code here. May be you don't close a MySql Reader or Connection before closing your program.

Nicolas C
  • 185
  • 1
  • 8
  • i found the problem. i was declared connection string in a module. then i removed it and separately declared it on every form that i using mysql. now that error is gone. and code is working fine. but i cant figure out why is that happen when i using a module to connect my database. if you know please let me know. and note ms sql is connecting fine by module. errors is only come when i trying to use mysql. thank you – Manujaya Kalanajith Aug 23 '15 at 14:52
0

You are trying to use something that is null (or Nothing in VB.NET). This means you either set it to null, or you never set it to anything at all.

What This Really Means

The runtime throwing a NullReferenceException always means the same thing: you are trying to use a reference. The reference is not initialized (or it was initialized, but is no longer initialized).

This means the reference is null, and you cannot access members through a null reference. The simplest case:

string name = null;
name.ToUpper();

or

string name = null;
name.ToLower();

These will throw a NullReferenceException at the second line, because you can't call the instance method ToUpper() or ToLower() on a string reference pointing to null.

AfterShotzZHD
  • 231
  • 4
  • 14
  • thank you for your rply. but i found the problem. i was declared connection string in a module. then i removed it and separately declared it on every form that i using mysql. now that error is gone. and code is working fine. but i cant figure out why is that happen when i using a module to connect my database. if you know please let me know. and note ms sql is connecting fine by module. errors is only come when i trying to use mysql. thank you – Manujaya Kalanajith Aug 23 '15 at 14:56
  • so you where not declaring it at all as i mentioned above. Sorry i can't help any further. – AfterShotzZHD Aug 23 '15 at 16:06