Upgrades Questions on upgrading to version 6.x.
Version 6.x > Upgrades > Kentoco CMS v6 error View modes: 
User avatar
Member
Member
sabuj-matrixnmedia - 1/3/2012 4:10:24 AM
   
Kentoco CMS v6 error
Hello,

There are lot of changed between Kentico CMS v5 and Kentico v6.
Also v5 code not run in v6 kentico server.

Example we userd this code in our kentico web part v5.
GeneralConnection genConn = InitDbConn();
object[,] lParameters = new object[5, 3];
lParameters[0, 0] = "@ParamFromLoc";
lParameters[0, 1] = locName;
lParameters[1, 0] = "@ParamFromLat";
lParameters[1, 1] = latPos;
lParameters[2, 0] = "@ParamFromLon";
lParameters[2, 1] = lonPos;
lParameters[3, 0] = "@ParamMaxDist";
lParameters[3, 1] = redius;
lParameters[4, 0] = "@MarketingLevel";
lParameters[4, 1] = passVal;

And it gives this error..

[Error loading the WebPart 'HotelsDisplay']
d:\home\Default\airportcodesdatabase.com\htdocs\CMSWebParts\MyWebParts\cmshotelsdisplay.ascx.cs(1098): error CS1502: The best overloaded method match for 'CMS.DataEngine.GeneralConnection.ExecuteQuery(string, CMS.SettingsProvider.QueryDataParameters, string, string)' has some invalid arguments

The we used this for Kentico CMS v6 and it fixed the error.

QueryDataParameters lParameters = new QueryDataParameters();
lParameters.Add("@ParamFromLoc", locName);
lParameters.Add("@ParamFromLat", latPos);
lParameters.Add("@ParamFromLon", lonPos);
lParameters.Add("@ParamMaxDist", redius);
lParameters.Add("@MarketingLevel", passVal);



Also it don’t work this kind of Connection string init.

UserInfo admin = UserInfoProvider.GetUserInfo("administrator");
GeneralConnection genConn = ConnectionHelper.GetConnection(HotelCMSLibFunction.ConnectionString(), admin.UserID);

And this type of Connection string initialization not works too...

SqlDataSource1.ConnectionString = ConnectionHelper.GetConnection().ConnectionString;

User avatar
Member
Member
kentico_michal - 1/6/2012 1:21:10 AM
   
RE:Kentoco CMS v6 error
Hello,

There were some API changes in Kentico CMS 6.0 so you will need to adjust your code.

To get the connection string, please use one of these following functions:

// this property returns the default connection string called CMSConnectionString
string connectionString = SqlHelper.ConnectionString;

// this method can be used to get any connection string
string connectionString = ConnectionHelper.GetConnectionString(ConnectionStringName);


Some related information about API changes can be found in the following blog:
Changes in the API from version Kentico CMS 5.5 R2

Best regards,
Michal Legen