1

I'm trying to pass a parameter into a stored proc using ADO.NET. This paramater is of type int but the field in the database is nullable. Here's my code:

AddInParameter(cmd, "@i_Required_License_List_PKID", DbType.Int32, RequiredLicenseListPkid==""? null : Convert.ToInt32(RequiredLicenseListPkid); 

When I do this I get an error saying that there's no conversion between null and int.

I have also tried DbNull.Value in place of null but with the same result.

I can't seem to find any nullable parameter types in the DbType class but I wonder is that the solution.

2 Answers 2

2

Use: DBNull.Value;

as the value of the parameter

Sign up to request clarification or add additional context in comments.

Comments

0

AddInParameter(cmd, "@i_Required_License_List_PKID", DbType.Int32, RequiredLicenseListPkid==""? DBNull.Value: Convert.ToInt32(RequiredLicenseListPkid);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.