Change profile custom field type (Sitefinity 6.3) - sitefinity

I have an old installation of Sitefinity (version 6.3)
On the profile, I have a custom field that is numeric. I now have the needs to change this to hold a string instead.
What I found was that there is no easy way to change datatype (https://www.progress.com/documentation/sitefinity-cms/edit-an-existing-custom-field), but is It possible by code/config?
I'm guessing that one option is to delete the field, and then recreate it is a possibility, but since I have much data it would be a lot of work to restore data in the field. Is this the only way?
Edit: I've deleted the column and recreated it as a string/varchar.
I'm now facing a problem with some type of converter
type converter initialization failed. The converter with name 'DecimalConverter' does not convert from CLR type 'System. String' to SQL type 'DECIMAL'.
Parameter name: converterName
Actual value was OpenAccessRuntime.Data.DecimalConverter, Telerik.OpenAccess.Runtime, Version=2013.3.1211.3, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342.
This line in stack trace is of importance
[MetadataException: The metadata for field 'CustomerNo_sv' of class 'Telerik.Sitefinity.Security.Model.SitefinityProfile' cannot be initialized: Type converter initialization failed. The converter with name 'DecimalConverter' does not convert from CLR type 'System. String' to SQL type 'DECIMAL'.
Parameter name: converterName
Actual value was OpenAccessRuntime.Data.DecimalConverter, Telerik.OpenAccess.Runtime, Version=2013.3.1211.3, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342.]
Somehow the language specified values isn't converted as I can see. Now the whole site is down and I can't reach backend. So I guess I have to solve this out in DB?

What I do in similar cases is this:
I create the new field and then populate the new column in the database with the values from the old column (field).
In your case, you'd be looking at the sf_sitefinity_profile table.
This way the data will be migrated to the new field.
After that you can delete the old field and start using the new one.

Related

can not get a type of DBGrid Column, free pascal

I use a free pascal lazarus. I have DBGrid that loads table from DB. I created columns in designer and sqlqueries to these columns. Everything is excellent. But when i need to get type of field i get an error: Project Admin raised exception class 'External: SIGSEGV'. I do it like this:
var s:Variant;
begin
s:=Column.FieldName; // there is ok. I get right column name
s:=Column.Field.FieldKind;//here i get an error
Thanks.

String was not recognized as a valid Boolean Error on varchar column

I am getting this error:
String was not recognized as a valid Boolean.Couldn't store <No> in meetsstd Column. Expected type is Boolean
When I am running this query:
SELECT * FROM work_nylustis_2013_q3.nylustis_details WHERE siteid = 'NYLUSTIS-155718' LIMIT 50
From this code:
Adapter.SelectCommand = New NpgsqlCommand(SQL, MLConnect)
Adapter.Fill(subDT) ' This line throws error
The meetsstd field is a varchar(3) and it does store either a 'Yes' or a 'No' value. How is this getting this confused with a boolean - a varchar should not care whether is holds 'Yes', or 'Si', or 'Oui'? And it only happens on 27 records out of the 28,000 in the table.
I usually blame npgsql for this kind of strangeness, but the last entry in the stack trace is: System.Data.DataColumn.set_Item(Int32 record, Object value)
Any clues?
Thanks!
Brad
To check if it is problem with database or with driver you can reduce problem to one row and column using your current environment:
SELECT meetsstd FROM work_nylustis_2013_q3.nylustis_details WHERE sitenum=1
(of course you must change sitenum into primary key)
Then try such query using psql, pgAdmin or some JDBC/ODBC based general editor.
If psql shows such record which raises error with your Npgsql based application then problem is with Npgsql driver or problem is with displaying query results.
If other tools shows such strange errors then problem is with your data.
Have you changed type of meetsstd field? Mayby you try to show it on some grid and this grid used Boolean field which was converted to Yes/No for displaying?

SQL Server Compact Query Analyzer: How to change part of a string value in a table?

I have an SQL Server Compact Edition 4.0 database file which has .sdf extension. The database is created by a book cataloging application. The database has many tables, among them a table called Book which contains one row for each book in the database. The table has many columns among them a column called FrontCover which contains a string value which has 2 parts: path part and file name part of the image file for the front cover of a book, for example:
Documents and Settings\Boson\My Documents\Books\Covers\0596003978.jpg
In this example path part is:
'Documents and Settings\Boson\My Documents\Books\Covers'
while file part is:
'0596003978.jpg'
Some books do not contain any value for the column FrontCover because the front cover is not available. For such books column FrontCover is empty. However if a book has a front cover image file then the string value has the same path part but different file part. For example for another book column FrontCover has this value:
'Documents and Settings\Boson\My Documents\Books\Covers\1590596633.jpg'
As we can see the path part is the same as in the first example, namely:
'Documents and Settings\Boson\My Documents\Books\Covers'
but the file part is different:
'1590596633.jpg'
PROBLEM:
I want to change the whole table Book so that string values of the column FrontCover are modified for every book in the table in such a way that file part is kept the same but the path part is changed from:
'Documents and Settings\Boson\My Documents\Books\Covers'
to
'Books\AEM database\Covers'
The string value of the column FrontCover for the book in the first example would thus change from:
'Documents and Settings\Boson\My Documents\Books\Covers\0596003978.jpg'
to
'Books\AEM database\Covers\0596003978.jpg'
File part is the same but the path part is changed. I want to change the whole Book table so that the file part of the string value for column FrontCover is kept the same but the path part is changed as specified above.
The book cataloging application which owns the .sdf database file is stupid and cannot do the job. Therefore I have installed a simple open source SQL viewing/editing application called SQL Compact Query Analyzer (http://sqlcequery.codeplex.com/). SQL Compact Query Analyzer can open .sdf database files and accepts SQL commands in order to modify the .sdf database file.
Can you please help me with the SQL commands which can do the job?
Thank you very much in advance for your help.
best regards
UPDATE Book SET FrontCover = REPLACE(
CAST(FrontCover AS NVARCHAR(300)),
'Documents and Settings\Boson\My Documents\Books\Covers',
'Books\AEM database\Covers')
WHERE FrontCover like
'Documents and Settings%'
Note: the where clause may not be necessary but it ensures that you only replace strings that start with 'Documents and Settings...'
The answer posted by Paul Brown is OK however it produced the following error code:
ErrorCode: -2147467259 [SQL Server Compact ADO.NET Data Provider] HResult: -2147217900, NativeError: 25922 ErrorMessage: The specified argument value for the function is not valid. [ Argument # = 1,Name of function(if known) = REPLACE ]
The reason for this is because the type of date for the column FrontCover is NTEXT (I forgot to specify that in my question) and function REPLACE does not allow NTEXT variable. So we have to covert FrontCover variable with the following command before passing it to REPLACE:
CAST(FrontCover AS NVARCHAR(100))
Therefore the answer to my question is:
UPDATE Book
SET FrontCover = REPLACE (CAST(FrontCover AS NVARCHAR(100)), 'Documents and Settings\Boson\My Documents\Books\Covers\', 'Books\AEM database\Covers\')

.NET ODBC Oracle Params getting param name returned by db provider- possible?

I'm converting some RDO code to ODBC Provider code in .NET.
The problem is parameter names were not specified in the orignal code, but param values were retrieved by parameter name after the command was executed.
Is there anyway to have parameter names populated by the provider once the command is executed so calling code can access params by name.
Let me show you an example of the declaration of param and accessing of it.
With rdqryClntBasic
.Parameters.Add(.CreateParameter) : .Parameters(0).Direction = ParameterDirection.Input
.Parameters(0).DbType = DbType.String
.Parameters(0).Value = sClntProdCd
End With
.EffectiveDate = ToDate(rdqryClntBasic.Parameters("dtEffDt").Value)
You can now see how this "used to work in RDO/VB". For some reason it would accept this and know what the param names were after execution. I imagine it had to do another round trip to the db to get this info.
Is there anyway to mimic this behaviour in .NET for ODBC Provider (using Oracle)? Or am I stuck manually specifying the param names in the code (I understand this is the better option, but wondering what the alternative is to match the original code as closely as possible).
No, parameters in ODBC are positional not by name.

How does NHibernate Projections.Max work with an empty table?

I'm trying to get the maximum value of an integer field in a table. Specifically, I'm trying to automatically increment the "InvoiceNumber" field when adding a new invoice. I don't want this to be an autoincrement field in the database, however, since it's controlled by the user -- I'm just trying to take care of the default case. Right now, I'm using
session.CreateCriteria<Invoice>()
.SetProjection(Projections.Max("InvoiceNumber"))
.FutureValue<int>();
to get the biggest invoice number already in the database. This works great, except when there are no invoices already in the database. Then I get a System.ArgumentException: The value "" is not of type "System.Int32" and cannot be used in this generic collection. Changing to FutureValue<int?>() didn't solve the problem. Is there a way to tell NHibernate to map the empty string to null? Or is there a better way to accomplish my goal altogether?
The stack trace of the exception (at least the relevant part) is
NHibernate.HibernateException: Error executing multi criteria : [SELECT max(this_.[InvoiceNumber]) as y0_ FROM dbo.[tblInvoice] this_;
SELECT this_.ID as ID647_0_, this_.[NHVersion] as column2_647_0_, this_.[Description] as column3_647_0_, this_.[DiscountPercent] as column4_647_0_, this_.[DiscountDateDays] as column5_647_0_, this_.[PaymentDueDateDays] as column6_647_0_, this_.[Notes] as column7_647_0_, this_.[DiscountDateMonths] as column8_647_0_, this_.[PaymentDueDateMonths] as column9_647_0_, this_.[DiscountDatePeriod] as column10_647_0_, this_.[DiscountDateMonthlyDay] as column11_647_0_, this_.[DiscountDateMonthlyDayDay] as column12_647_0_, this_.[DiscountDateMonthlyDayMonth] as column13_647_0_, this_.[DiscountDateMonthlyThe] as column14_647_0_, this_.[DiscountDateMonthlyTheDOW] as column15_647_0_, this_.[DiscountDateMonthlyTheMonth] as column16_647_0_, this_.[DiscountDateMonthlyTheWeek] as column17_647_0_, this_.[PaymentDueDatePeriod] as column18_647_0_, this_.[PaymentDueDateMonthlyDay] as column19_647_0_, this_.[PaymentDueDateMonthlyDayDay] as column20_647_0_, this_.[PaymentDueDateMonthlyDayMonth] as column21_647_0_, this_.[PaymentDueDateMonthlyThe] as column22_647_0_, this_.[PaymentDueDateMonthlyTheDOW] as column23_647_0_, this_.[PaymentDueDateMonthlyTheMonth] as column24_647_0_, this_.[PaymentDueDateMonthlyTheWeek] as column25_647_0_ FROM dbo.[tblTermsCode] this_;
] ---> System.ArgumentException: The value "" is not of type "System.Int32" and cannot be used in this generic collection.
Parameter name: value
at System.ThrowHelper.ThrowWrongValueTypeArgumentException(Object value, Type targetType)
at System.Collections.Generic.List`1.VerifyValueType(Object value)
at System.Collections.Generic.List`1.System.Collections.IList.Add(Object item)
at NHibernate.Impl.MultiCriteriaImpl.GetResultsFromDatabase(IList results)
use....UniqueValue<int?>();
NH uses a non-generic IList in their MultiCriteria implementation. Which is used for FutureValue batching. see here for why List<int?> fails to add null through it's IList implementation. I'm surprised I've never run into this before. Avoid using nullable value types with Future or MultiCriteria.
With the QueryOver API:
Session.QueryOver<T>()
.Select(Projections.Max<Statistic>(s => s.PeriodStart))
.SingleOrDefault<object>();
if nothing is returned its null, otherwise cast the result as numeric