Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Error in SP2013 when a custom .wsp tries to bring data from database

$
0
0

Hi All, i have a very particular problem with a .wsp. I ´ve developed a webpart to search data on a MySQL database.

The .wsp worked fine until i realized that different instances of the webpart where sharing the custom properties. The problem was that those properties where developed like this:

private static string dataBase;

[WebBrowsable(true),
WebDisplayName("Database"),
WebDescription("Database"),
Personalizable(PersonalizationScope.Shared),
Category("DB Connection")]
public string _dataBase
{
   get { return dataBase; }
   set { dataBase = value; }
}

And the answer was declaring those properties like this:

[WebBrowsable(true),
WebDisplayName("Database"),
WebDescription("Database"),
Personalizable(PersonalizationScope.Shared),
Category("DB Connection")]
public string dataBase
{
   get;
   set;
}

But like this, when the webpart try to read from the database, it gives an error in the Sharepoint site. The error doesn´t say anything important, and in the errors log it says that the database doesn´t exists which isn´t true.

The connection is made successfully to the database, but when i try to define a datareader occurs the error. The line when this happens:

MySqlDataReader dataReaderDB = commandByDateDB.ExecuteReader();

ADDITIONAL DATA:

If the connections variables are hardcoded as private

private string dataBase = "mydatabase";

the webpart works.

Another data is that i´ve two servers with SP2013, one for development with the Visual Studio 2012 installed, and another for testing, without Visual Studio 2012. The problem ONLY occurs on the testing server, and i cant install VS2012 on the testing server to debug the error (due to administration decisions)

Any help to give an end to this problem will be great.

THANKS IN ADVANCE




Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>