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

  • Home
  • SEARCH
  • 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 8662551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:45:39+00:00 2026-06-12T16:45:39+00:00

Hi I have a excel VB Program that pulls info from a database. My

  • 0

Hi I have a excel VB Program that pulls info from a database. My code for the function in question is below. This code WAS working for years, now i am getting an error: “Error converting datatype nvarchar to bigint” Why would this happen all of a sudden and what is the fix?

Public Function GetGiftCardsRedeem(iColumn As Integer, sFrom As String, sTo As String)

    Dim rsResults As New ADODB.Recordset
    Dim sSQL As String
    Dim iRecordCount As Integer

    ' Assign the Connection object.
    rsResults.ActiveConnection = gcnnDB

    ' Extract the required records.
    sSQL = "Select Sum(dTotalAmount) as TotalAmount from GiftCardTransactions where dtCreated between '" & sFrom & " 00:00:00' and '" & sTo & " 23:59:59'"
    sSQL = sSQL & " and CONVERT(BigINT, sCCNumber) Between 800110110000 and 800110159999" '800110110000
    sSQL = sSQL & " and not sCCNumber is null and sCCNumber <> ''"


    rsResults.Open sSQL, gcnnDB, adOpenStatic, adLockReadOnly, adCmdText
    If Not rsResults.EOF Then
        'Let's Cycle through the records..
        'We need to move last and then move back first to get a correct recordCount.

        DoEvents: DoEvents

        Sheet1.Cells(MTD_FREEGIFTCARDS_QTY_ROW, iColumn) = rsResults.Fields("TotalAmount").Value
    End If
    rsResults.Close
End Function
  • 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-12T16:45:40+00:00Added an answer on June 12, 2026 at 4:45 pm

    It would happen if somehow a non-numeric value was inserted into your sCCNumber field. The fix would be to find that value and fix it.

    Or you could replace

    and sCCNumber <> ''
    

    with

    and ISNUMERIC(sCCNumber) = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I basically have a program that filters records from one excel file to another
I have an Excel spreadsheet that I have exported from some other program. It
I have a program that takes data from an excel file and manipulates it
I have a little gui program that on startup reads data from an Excel
We have an asp.net c# program that reads a sheet from an Excel file
I have a python program that calls a stored procedure from db2 database. I
I have a vb program that reads data from an excel sheet and displays
I have a series of big excel files that work like a program, but
I have a C# program that is out putting results to an excel spread
I have a C# program that is creating, writing, and saving an excel file

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.