Tuesday, December 11, 2012

Check string Null or Empty in ASP.NET and Sql Server

In ASP.NET we can use IsNullOrEmpty method to check whether the string is null or contains an empty string.

string str="test";
if (string.IsNullOrEmpty(str))
// Code goes here

In Sql server we can use the below code.

Declare @Address='sri lanka'

IF @Address IS NOT NULL AND LEN(@Address)>0
// Code goes here

No comments:
Write comments
Recommended Posts × +