Re: How to check for query field length by Teemu
Teemu
Thu Jan 27 01:39:49 CST 2005
Hi,
In VB.NET you can use IsDBNull function, or generally Convert.IsDBNull to
check if it is DBNull or if working with DataReader then its own IsDbNull
method.
You could create general class for the mostly used types to convert it to
certain type and check for null. For example NZ.GetString(argument) which
returns String.Empty if argument is DBNull and otherwise return the value
converted to string. You could pass fields straight from DataReader or
DataSet to this method to perform the conversion for UI.
--
Teemu Keiski
ASP.NET MVP, Finland
"Kurt Schroeder" <KurtSchroeder@discussions.microsoft.com> wrote in message
news:0A439DCD-1A9A-498D-908A-333D0075ED77@microsoft.com...
> I have the follow asignment: txtDescription.Text =
> dtrSlb("slbDesc2")
> If the field returned is Null i get a run time error.
> I can check for if (dtrSlb("slbDesc1").GetType.ToString() =
> "System.DBNull")
> then .... But there has to be a better way.
> Aslo what's the best way t oget the length of the returned field from a
> query?
> Thanks for help on this simple question
> kes