Reputation: 5233
I have a table in AS/400 DB2 table:
SCDSC VARCHAR(120) CCSID 1208 DEFAULT NULL ,
CCSID 1208 implies UTF-8.
In my c# code this is the definition that works.
cmd.Parameters.Add("scdsc", OleDbType.VarChar , 120);
i have tried also with VarWChar type:
cmd.Parameters.Add("scdsc", OleDbType.VarWChar , 120);
The problem is that the maximum that this field gets is 60 characters. I cant make it work with 60 characters length in the field.
I find it odd that i need to double the true length of my fields (i did it for all my string fields) in order to make it work.
UPDATE: Correct implementation is to define the fields in DB as nvarchar and oledbtype as varWchar.
Upvotes: 1
Views: 1576
Reputation: 140228
You should define the column as nvarchar. You are defining it varchar 120, which means it can only hold 120 bytes, instead of the needed 240.
The varchar type is for non-unicode, 1byte=1character strings.
Upvotes: 1