Checking for null

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Andy G (ajgould_at_iastate.edu)
Date: 11/22/04


Date: Mon, 22 Nov 2004 13:26:51 -0600

I'm getting this error...Operator is not valid for type 'DBNull' and string
"". What is happening is that I'm calling a stored procedure to use the
email address to recover a forgotten username. If the email does not exist
then I get the above error. After I execute the stored procedure I try and
apparenty this is not catching the error. Should I use a Try...Catch? What
is the correct way to check for nulls in ASP.NET?

If Not myCommand.Parameters("@LOGIN_NAME").Value = "" Then

returnLogin = myCommand.Parameters("@LOGIN_NAME").Value

Else

lblMessage.Text = "Email does not exist in system. Re-enter email or contact
BRM Support"

End If



Relevant Pages

  • RE: SQL stored procedure executing twice
    ... from one parent record to another. ... Dim stDocName As String ... My pass-thru query syntax going to stored procedure ...
    (microsoft.public.access.modulesdaovba)
  • RE: MS Query "Connections"
    ... handle that with my connection string. ... for using the stored procedure route is that it is faster. ... If you truly want to pass in the query string, ...
    (microsoft.public.excel.programming)
  • Re: XML binding advice
    ... Performance - By writing the SQL statement as a stored procedure, ... execution plan will take into account any indexes you have on the tables ... each piece you add to the string. ...
    (microsoft.public.dotnet.xml)
  • Re: TableAdapter specifing IN in the where clause for list of id
    ... And till now, there products which are huge products, they are using AD-HOC ... Since IN cannot accept a delimited string but ... Muhammad replied that I could use a stored procedure to accomplish this ... specify. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Creating A Custom Collection
    ... You'll have to get away from using multidimensional arrays. ... > string StoredProcedureName, string UserName, string TransactionType ... > stored procedure so it can walk this object to create a SqlCommand ... > send the name of the proc and the parameters object to the data layer ...
    (microsoft.public.dotnet.framework)