stored procedure execute.nonquery-String[1]: the Size property has an invalid size of 0


Hi

Recently while calling the store procedure using Output Parameter in asp.net, I was getting this error,

String[1]: the Size property has an invalid size of 0

There was returning the values as string from SP. I solverd the error by giving size of “SqlDbType.NVarChar” like this

using (SqlCommand cmd = new SqlCommand(“Test_Delete”, con))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue(“@QmsId”, objBE.qmsId);
cmd.Parameters.Add(“@FileUrl”, SqlDbType.NVarChar,1000).Direction = ParameterDirection.Output;
//cmd.Parameters.Add(“@FileUrl”, objBE.fileURL);
con.Open();
cmd.ExecuteNonQuery();
fileUrl = cmd.Parameters[“@FileUrl”].Value.ToString();
return fileUrl;
}

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.