Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send String.Empty to stored procedure

Considering this example:

MyParameters.Name = "Paul";
MyParameters.Nickname = String.Empty;

ExecuteStoredProcedure(MyStoredProcedure, MyParameters);

When my stored procedure executes it will run something like this?

MyStoredProcedure 'Paul',''

So, my question is: C# String.Empty is equal to Database ''?

PS.: I'm using SQL Server

like image 655
guisantogui Avatar asked Feb 13 '23 00:02

guisantogui


1 Answers

Yes, an empty string is sent as an empty string. See, the values are translated and sent as expected. For example, if you needed to send null then you'd set Nickname like this:

MyParameters.Nickname = null;

Your code is also equivalent to:

MyParameters.Nickname = "";
like image 84
Mike Perrenoud Avatar answered Feb 16 '23 02:02

Mike Perrenoud