Does anybody have an idea how to import the dictionary items that we have in excel to the database. I try the import tool of sql server but I'm having a problem with the data because the uniqueId is being read as varchar in excel and it can't convert to uniqueidentifier which is the datatype in sql server.
My approach to this would be to deal with the APIs rather than going to the database directly.
I haven't had much experience with accessing/reading data from Excel in C#/.NET, but it is definitely possible. Then once you have got access to the data, you can add new dictionary items via the API.
My mistakes but I already have the dictionary item but what I meant is to upload the text in other language which I think will use the cmsLanguageText table. Is there any api for that?
Currently I use the SQL directly to insert the language item. I was able to insert it in the table but when I try to check the Dictionary in the backoffice it's not populating the textboxes for the other language. It seems that it didn't read the recently inserted languaget text.
This is my code.
SqlCommand dCmd = newSqlCommand("INSERT INTO cmsLanguageText(languageId,UniqueId,[value]) values (@languageId, @key, @value)"
With the SqlCommand, what value are you passing through as the "@key" parameter? It should be the Guid for the DictionaryItem (which is the "id" from the "cmsDictionary" table).
I'd still recommend doing this via the appropriate API. :-)
If you want to use the API, what was the exception message? From looking at the core code, it should only throw an "ArgumentException" if the dictionary key doesn't exist.
Otherwise, going down the direct database route, you'd need to investigate further - check if the Guid differs, etc. Also the Umbraco back-office caches the DictionaryItems, so remember to touch the web.config (or restart app-pool).
No other exception message besides the stack overflow message which makes it difficult also for me to debug. Probably i'll go first with the direct database route.
importing dictionary items from excel
Hi,
Does anybody have an idea how to import the dictionary items that we have in excel to the database. I try the import tool of sql server but I'm having a problem with the data because the uniqueId is being read as varchar in excel and it can't convert to uniqueidentifier which is the datatype in sql server.
Thanks,
Sherry
Hi Sherry,
My approach to this would be to deal with the APIs rather than going to the database directly.
I haven't had much experience with accessing/reading data from Excel in C#/.NET, but it is definitely possible. Then once you have got access to the data, you can add new dictionary items via the API.
Cheers, Lee.
Hi Lee,
My mistakes but I already have the dictionary item but what I meant is to upload the text in other language which I think will use the cmsLanguageText table. Is there any api for that?
Hi Sherry,
No problem if the dictionary item already exists, just need to know the "languageId", then you can call...
The 'setValue' method will handle the insert/update database calls.
Cheers, Lee.
Hi Lee,
Currently I use the SQL directly to insert the language item. I was able to insert it in the table but when I try to check the Dictionary in the backoffice it's not populating the textboxes for the other language. It seems that it didn't read the recently inserted languaget text.
This is my code.
SqlCommand dCmd = newSqlCommand("INSERT INTO cmsLanguageText(languageId,UniqueId,[value]) values (@languageId, @key, @value)"
);
dCmd.CommandType =
CommandType
.Text;
dCmd.Connection = conn;
dCmd.Parameters.AddWithValue(
"@languageId"
, languageID);
dCmd.Parameters.AddWithValue(
"@key"
, key);
dCmd.Parameters.AddWithValue(
"@value"
, value);
dCmd.ExecuteNonQuery();
dCmd.Dispose();
Hi Sherry,
With the SqlCommand, what value are you passing through as the "@key" parameter? It should be the Guid for the DictionaryItem (which is the "id" from the "cmsDictionary" table).
I'd still recommend doing this via the appropriate API. :-)
Cheers, Lee.
Yes it is a GUID
This is my code for that
key =
newGuid(reader["UniqueID"
].ToString());
But I'm having a problem using the api. I'm getting a stack overflow error in this line
var
item = newDictionary.DictionaryItem
(key);
It is not giving me any error so I can't pinpoint which went wrong.
Not sure if you've copy-n-paste the code... but add a space between "newDictionary" ... "new Dictionary"?
There is a space on my code. :)
I'm just having problem pasting code in here.
If you want to use the API, what was the exception message? From looking at the core code, it should only throw an "ArgumentException" if the dictionary key doesn't exist.
Otherwise, going down the direct database route, you'd need to investigate further - check if the Guid differs, etc. Also the Umbraco back-office caches the DictionaryItems, so remember to touch the web.config (or restart app-pool).
Cheers, Lee.
No other exception message besides the stack overflow message which makes it difficult also for me to debug. Probably i'll go first with the direct database route.
No worries. Good luck with it. (Not sure what else to suggest, sorry).
Let us know how it goes.
Cheers, Lee.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.