|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
if result = system.dbnullin the command window I get:
? result {System.DBNull} [System.DBNull]: {System.DBNull} I need to check for this in code. I then tested in the command window if result = system.DBNull 'DBNull' is a type and cannot be used as an expression. How can I check to see if result is equal system.dbnull in my code? Either of the following:
If IsDBNull(result) Then... If result = DBNull.Value Then... Show quoteHide quote "cj" <cj@nospam.nospam> wrote in message news:OaXJp1qRGHA.4688@TK2MSFTNGP11.phx.gbl... > in the command window I get: > > ? result > {System.DBNull} > [System.DBNull]: {System.DBNull} > > I need to check for this in code. I then tested in the command window > > if result = system.DBNull > 'DBNull' is a type and cannot be used as an expression. > > How can I check to see if result is equal system.dbnull in my code? Thanks. I'll go with IsDBNull(result)
Marina Levit [MVP] wrote: Show quoteHide quote > Either of the following: > > If IsDBNull(result) Then... > If result = DBNull.Value Then... > > "cj" <cj@nospam.nospam> wrote in message > news:OaXJp1qRGHA.4688@TK2MSFTNGP11.phx.gbl... >> in the command window I get: >> >> ? result >> {System.DBNull} >> [System.DBNull]: {System.DBNull} >> >> I need to check for this in code. I then tested in the command window >> >> if result = system.DBNull >> 'DBNull' is a type and cannot be used as an expression. >> >> How can I check to see if result is equal system.dbnull in my code? > >
Show quote
Hide quote
"cj" <cj@nospam.nospam> wrote in message Perhaps this will help:news:OaXJp1qRGHA.4688@TK2MSFTNGP11.phx.gbl... > in the command window I get: > > ? result > {System.DBNull} > [System.DBNull]: {System.DBNull} > > I need to check for this in code. I then tested in the command window > > if result = system.DBNull > 'DBNull' is a type and cannot be used as an expression. > > How can I check to see if result is equal system.dbnull in my code? Visual Basic (Declaration) Public Shared Function IsDBNull ( _ value As Object _ ) As Boolean Visual Basic (Usage) Dim value As Object Dim returnValue As Boolean returnValue = Convert.IsDBNull(value) -- Peter [MVP Visual Developer] Jack of all trades, master of none. I think I sww where you're going with this but I've already changed it
to one of Marina Levit's ideas. Also I'm not sure how all this would fit in with, result is declared as an object. My intention was to declare result as a string but it turns out when there is nothing to put in it instead of it getting a null string it gets dbnull. arrrrgh! So now result is a object and I can check to see if it's dbnull if not it's a string. Seems to work. So perhaps I can finish this darn program now. pvdg42 wrote: Show quoteHide quote > "cj" <cj@nospam.nospam> wrote in message > news:OaXJp1qRGHA.4688@TK2MSFTNGP11.phx.gbl... >> in the command window I get: >> >> ? result >> {System.DBNull} >> [System.DBNull]: {System.DBNull} >> >> I need to check for this in code. I then tested in the command window >> >> if result = system.DBNull >> 'DBNull' is a type and cannot be used as an expression. >> >> How can I check to see if result is equal system.dbnull in my code? > > Perhaps this will help: > > Visual Basic (Declaration) > Public Shared Function IsDBNull ( _ > value As Object _ > ) As Boolean > > Visual Basic (Usage) > Dim value As Object > Dim returnValue As Boolean > > returnValue = Convert.IsDBNull(value) > >
Show quote
Hide quote
"cj" <cj@nospam.nospam> schrieb If result is DBnull.value then> in the command window I get: > > ? result > {System.DBNull} > [System.DBNull]: {System.DBNull} > > I need to check for this in code. I then tested in the command > window > > if result = system.DBNull > 'DBNull' is a type and cannot be used as an expression. > > How can I check to see if result is equal system.dbnull in my code? Armin "cj" <cj@nospam.nospam> schrieb: 'If x Is DBNull.Value Then...' or 'If IsDBNull(x) Then...'.> How can I check to see if result is equal system.dbnull in my code? -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
Adding Button Programmatically REDUX - STILL NONFUNCTIONAL
VB.NET Automatic code typing features "ambiguous" problem with VB.NET 2005 ComboBox ReadOnly Help with first multi-thread app pls? Direct input into DataGrid? Please help! Database won't update Visual Basic .net and DirectX Access a textbox on a report form DataGridView : selected-record changes after sorting ??? |
|||||||||||||||||||||||