Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#: DbType.String versus DbType.AnsiString

Tags:

I have taken over some C# code.

The code is hitting a database with some SQL which uses parameters.

All of the string parameters are typed as DbType.AnsiString instead of DbType.String.

Why would you use DbType.AnsiString instead of DbType.String?

like image 482
Craig Johnston Avatar asked Mar 08 '11 07:03

Craig Johnston


1 Answers

AnsiString
A variable-length stream of non-Unicode characters ranging between 1 and 8,000 characters.

String
A type representing Unicode character strings.

In database:

nchar and nvarchar is unicode

char and varchar is non-unicode

like image 197
edze Avatar answered Oct 27 '22 02:10

edze