Problme using nullable parameters from vb.net

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

vb2005/sqlserver2005. I have a stored procedure that accepts three optional
parameters. If I run the following it returns the data fine;

DECLARE @return_value int
EXEC @return_value = [dbo].[NewSelectCommand]
@CompanyType = NULL,
@Status = NULL,
@BusinessDivision = NULL

If however I use the following in my vb.net app, I get nothing.

Me.CompaniesTableAdapter.Fill(Me.EMSDataSet.Companies,
DBNull.Value.ToString, DBNull.Value.ToString, DBNull.Value.ToString)

What is the problem and how can I fix it?

Thanks

Regards
 
Try using System.Data.SqlTypes.SqlString.Null for your parameter values. If
your parameters are not strings there are additional types in the SqlTypes
namespace for the different SQL data types.
 
John said:
vb2005/sqlserver2005. I have a stored procedure that accepts three
optional parameters. If I run the following it returns the data fine;

DECLARE @return_value int
EXEC @return_value = [dbo].[NewSelectCommand]
@CompanyType = NULL,
@Status = NULL,
@BusinessDivision = NULL

If however I use the following in my vb.net app, I get nothing.

Me.CompaniesTableAdapter.Fill(Me.EMSDataSet.Companies,
DBNull.Value.ToString, DBNull.Value.ToString, DBNull.Value.ToString)

What is the problem and how can I fix it?

I don't really know what DBNull.Value.ToString() returns, but it is
not likely to be a NULL value. My guess goes for the string "NULL" which
is something completely different.

In any case, you desperately need to be more discriminate in your selection
of newsgroups, or else people will grew tired of you quickly.
 
Back
Top