Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8928911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:33:26+00:00 2026-06-15T08:33:26+00:00

I am iterating through some rows/cells in an Excel sheet and some of the

  • 0

I am iterating through some rows/cells in an Excel sheet and some of the cells are blank. When I try to do the insert, if a cell contains no data, it advises me that that particular parameter has no default value. In Access, I have set the default value to “=Null” but I still receive the error. Do I have to do an If statement as shown below for every parameter in order to prevent errors? I’d like to clean up my code if possible.

If worksheet1.GetValue(i, 14) Is Nothing Then
                            cmd.Parameters.Add("@Param1", OleDbType.Char).Value = DBNull.Value
                        Else
                            cmd.Parameters.Add("@Param1", OleDbType.Char).Value = worksheet1.GetValue(i, 14)
                        End If
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:33:27+00:00Added an answer on June 15, 2026 at 8:33 am

    In my experience (albeit C#), yes you do. Interop (which is what I’m assuming you’re using although I don’t recognise the GetValue() call) usually throws an exception when you try to get data from an empty cell without first checking. The way I’ve handled it is to wrap the code in a method and just call it each time (sorry, my VB is a little rusty):

    Public Function GetCellContents(column As Integer, row As Integer) As String
    
        If worksheet1.GetValue(column, row) Is Nothing Then
            Return ""
        Else
            Return worksheet1.GetValue(column, row)
        End If
    
    End Function
    

    And then you can just do:

    cmd.Parameters.Add("@Param1", OleDbType.Char).Value = GetCellContents(i, 14);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm iterating through some objects and trying to set some properties that, apparently, don't
Often, I am building an array by iterating through some data, e.g.: my_array =
So I have a collection that I loop through to display some data. There's
I have to delete some rows from a data table. I've heard that it
I'm iterating through a variable called content, it contains several HTMLLIElement objects. How can
I was iterating through a table I had created and getting the first cell
I am iterating through a JSON object and I am getting the data and
I'm iterating through a List<> to find a matching element. The problem is that
I'm currently using jQuery and would like some help on iterating through all checked
I am working with Vaadin and I have some trouble iterating through choices in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.