Checking for Null values in ADO field


I am trying to check whether or not

HERE is my some of my code:
strSQL="SELECT ..."
Dim cn As OleDbConnection = New OleDbConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim cmdHeader As OleDbCommand = New OleDbCommand(strSQL, cn)
Dim rdHeader As OleDbDataReader
rdHeader = cmdHeader.ExecuteReader
So you can see that I am loading a OleDbDataReader from my table. This code works fine.
Now I want to check to see if one of the fields is null. I have tried ALL of the following:
If Val(0 & rdHeader("MeasuredQuoteDate")) = 0 Then
If IsDbNull(rdHeader("MeasuredQuoteDate")) THEN
Both of the efforts return the following error:
System.InvalidOperationException: No data exists for the row/column.
I have also tried to add to the Select something like this:
SELECT *, IsNull(MeasuredQuoteDate,0) AS MQD FROM...
And I get a wrong number of arguments for the IsNull function.
THIS SHOULDN'T be this hard. All I want to do is see if my Date field is null or not.
Please help.
Seth B Spearman

2/15/2004 9:16:08 PM 16182 articles. 0 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 6


I was not doing the rdHeader.Read()
Figured it out.
Seth B Spearman
2/15/2004 9:36:20 PM

Similar Artilces:

Check null value for an object
Hi,       How to check the object is null in C#. For the code below TextBox tbox = new TextBox(); tbox = (TextBox)Page.PreviousPage.FindControl("textboxFirstName"); i want to find whether the tbox is null or not. How can i achieve this in C#. Please help.  You can use the "as" keyword to try to cast the object. If the casting fails null is returned.  tbox =Page.PreviousPage.FindControl("textboxFirstName") as TextBox; HighOnCodingWanna get high! like this:TextBox tbox = (TextBox)Page.PreviousPage.FindControl("text...

ADO.NET to XML and null field
I am getting XML version of a Dataset using ds.GetXml(). If the db field is null or empty, how do I get the XML to emit a <fieldName /> rather then nothing? Thanks. Here's a couple articles on why it happens and some work arounds.;EN-US;296393;en-us;317961 Hmmm neither of those seem like a good work around for this problem - i would even go as far as to say bug in ADO.NET. Does anyone have any suggestions for me before I code my own function to interate through a RS and ...

check null value in file field
hi all I have  a upload form  i wan the form or URL  field is not empty , the the add  button can take action , for url is <asp:textbox id="txtLink1" runat="server">  I  can use If (txtLink1.Text <> "") Then but for  <INPUT class="txt2" id="oFile" type="file" size="40" name="oFile" runat="server">   i can't use oFile.Text<>"" so , what is the correct way to handle it Thank you Hi,  Try with this o...

Check Null value in Money data field.
How to check the null value in field whose datatype is money. default value in databse is - 0.0000    Am is getting value from  a money field. string Amount = llPrAmt.Text; Decimal Am = Decimal.Parse(Amount);  if (Am is null ){}    Dont make use of Decimal.Parse, use either Decimal.TryParse Or Convert.ToDecimal(llPrAmt.Text).Raghu(MCSD.NET, MCAD.NET, MCDBA)[Don't forget to click on Mark as answer on the post that helped you ]  Well you can check using DbNull.Valuesee

Handling NULL value in DW.NET ADO
Hi All! How to retrieve datawindow with NULL values?. The database i am using is SQL Server 2000. In Datawindow Designer 1.5 if i open the datawindow d_update_route and enter the arguments with null the data retrieved. but in runtime when i give the same NULL value as arguments it gives error. How to give NULL value as parameter in DW.NET in runtime? Public ao_sqlca As Sybase.DataWindow.AdoTransaction ----- With dw_flow_online .DWControlwidth = 763 .DWControlhight = 149 .DWLibrarylist = of_getFilePath("...

Checking for Null or Empty values in a Database Field.
I'm trying to perform a simple check to see if a database field that I am accessing through the DataReader is Null or Empty.  I've used the following code and the first If statement works fine, I get the desired results when my field value is <NULL>.  But some of the fields have no value at all and I would like to perform the same actions is that case.  My code is pasted below along with the error I get for the second If statement.Thanks. If IsDBNull(drReader("Remarks")) Then   Me.pnlRemarks.Visible = FalseElse   Me.lblRemarks.Text = drRead...

Problem with checking null value for an integer field
I am using a SQL database and i would like to check whether one of the Int field contains a NULL value?I try using the following statement but it gives me an error.Can someone help me to correct the statement? <coding> if (Convert.ToString(Reader2.GetInt32[4]) != DBNull.Value) { //do process } if(Reader2.GetValue[4] != dbnull.Value) Just a recommendation here, but you should attempt to avoid using NULL values whenever possible, especially on Integer fields. Set the default value on Integer based fields to 0 is IMO a better practice. Like I said, j...

Ultralite.NET check for NULL values in columns
I am using Developing with VB.NET using VS2005 I perform a select How do I check for a null value in a column before getting the value from the ULDataReader. c = GetConnectionInstance() cmd = c.CreateCommand() cmd.CommandText = "select col1,col2 from t1 where id = ?" parm = cmd.CreateParameter() parm.Value = theid cmd.Parameters.Add(parm) Dim r As ULDataReader = cmd.ExecuteReader() If (r.Read()) Then r.GetString(r.GetOrdinal("col1")) 'Check for null befor getting col2 r.GetString(r.GetOrdinal("col2")) End If Hi....

How can I pass a null value for an integer (value type) parameter and then check if this integer parameter is null?
Normally in VB.Net if I pass an integer parameter as 'Nothing', then in the called method this parameter is automatically set to zero. I want it to remain null so I can use the following code as it seems more intuitive than checking for 0 value: if moduleId is nothing then    'Do some processing here end if   In C#, I guess we can declare the parameter as int? moduleId and it can then be checked for null value.sun21170 The int? in C# is an example of using nullable types, which are a feature new to .NET 2.0. The ? is just syntactic sugar in the C# language....

DetailsView: conditionally hide field if value == null, but can't update the value of other fields
Hi, I need help please. I have made some fields hidden if their value is null by setting visible to false on the DetailsView1_Itemcreated event. I put the field's to the DataKeyNames, so that I can check the value is null or not when detailsview is at the readOnly mode.But, when I tried to edit, it throws an error: must declare a scalar for @...  so, i add some code in the DetailsView1_ItemUpdating: e.newValues["color"] = null; then the error is gone. but, the values for other fields are not updated. I already check the e.newValues["other fields"] , they all are ...

checking for a null value returned from a SELECT in
I am executing a SELECT statement, one time it is executed  the "category" does not exist in the db. How do I check that NULL was returned so I dont get an error trying to access it? At the moment I get the following error message "System.IndexOutOfRangeException: Index 0 is either negative or above rows count."  Dim category As StringDim productDV As DataViewDim arg As New DataSourceSelectArguments productDV = SqlDataSource1.Select(arg)     If Not IsDBNull(productDV(0)("Category")) Thencategory = LCase(productDV(0)("Categ...

Passing a data field value to a variable using ADO.NET
Hi, I’m already able to connect to a data base and to show a table content using a GridView, but I would like to test a manual way, like we just did it using the past ADO, giving a field value to a variable. In ADO we just did it:   strVariable = TABLE(“FIELD”),   But I have been trying to find something similar with ADO.NET, but every example I found show the data table using ASP Controls or instructions to display the information:   Any Help, Please?   Thanks. You can dig in to the data like this (gets 3rd row, 4th column): strVariable = MyTable.Rows[2].Item...

Insert NULL value into datetime field of Oracle database
 Hi all,I have a form which has a textbox where a date is entered by the user - this field is not compulsory so if it is left blank I want to store it in the table as nothing. However, when I use the code below it enters 01/01/0001 instead of nothing. I have tried various other options Endate.MinValue and EndDate = System.DBNull.Value (this throws an error)Im stumped. Anyone have any ideas as to how I can enter a blank value into a date field in my oracle table? Would prefer to do it before I go near the sql Insert (so in my code) because thats done using a stored procedure and w...

Updating fields with NULL values using ADO 2.5 and ASA 6.03
Hi I've seen numerous references in this newsgroup about the following problem but no solutions. Surely someone is sitting on a solution out there that they'd like to share with the rest of us - particularly me! If the following ADO syntax is used from within Visual Basic to update an Adaptive Server Anywhere varchar field a '' (zero-length) string results: MyRecordset.Fields("MyVarchar") = NULL This syntax works OK in Microsoft SQL Server but that's using a native OLEDB provider. I suspect it would also work with ASA 7 as it also have a nati...

Web resources about - Checking for Null values in ADO field -

Checking whether a coin is fair - Wikipedia, the free encyclopedia
In statistics , the question of checking whether a coin is fair is one whose importance lies, firstly, in providing a simple problem on which ...

Facebook As A Means Of Credit Checking
How you socialize online, who with, and how often can make or break your loan application : True or false? It is true, surprisingly. And it is ...

Checking in at the World Cup and Leaving with Friends
... to the 2014 World Cup and we wanted to take a closer look at those who used Facebook to stay connected while they were in Brazil, checking into ...

State of Journalism: The Lost Art of Fact Checking
... Read all the posts here.It wasn’t exactly Bright Lights, Big City. Jay McInerney’s well State of Journalism: The Lost Art of Fact Checking March ...

Diver Checking Underwater Protection of Cable - Flickr - Photo Sharing!
Diver checking underwater protection of cable at hydroacoustic station HA08 at the British Indian Ocean Territory (BIOT), U.K. Copyright CTBTO ...

ESPN's Ray Lewis caught checking his phone on live TV for 20 seconds - YouTube
The Indianapolis Colts are gearing up for a Monday night AFC East clash against the New York Jets. The Colts are looking for their first win ...

Q&A: Checking rego date
Hugo is wondering what is the best way to check vehicle registration date now that cars no longer have rego labels in NSW.

Q&A: Checking rego date
Hugo is wondering what is the best way to check vehicle registration date now that cars no longer have rego labels in NSW.

Australian police checking MH17 site
Independent monitors are helping Canberra negotiate with armed rebels over access to the MH17 crash site.

Q&A: Checking rego date
Hugo is wondering what is the best way to check vehicle registration date now that cars no longer have rego labels in NSW.

Resources last updated: 11/24/2015 1:43:30 AM