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 7309033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:39:27+00:00 2026-05-28T23:39:27+00:00

I have the follow code in my program where I hit a SQLCe database

  • 0

I have the follow code in my program where I hit a SQLCe database to append the results into a list. That part works, but instead of exiting the function ‘QueryDB’ it goes to the else statement and runs the function again, which will return a null value. I designed it this way becuase I wanted to check to make sure the database is open before I try to execute the SQL statement, and if it’s not open, call the method to open it and run through the function again.

Public Function QueryDB(ByVal strSQL As String) As List(Of String)

    Dim reader As SqlCeDataReader
    Dim results As New List(Of String)

    Using cmdAdd As New SqlCeCommand(strSQL, conn)
        If Me.checkConnection Then
            reader = cmdAdd.ExecuteReader()
            Do While reader.Read
                results.Add(reader.GetString(0))
            Loop

            Return results
            Exit Function

        Else
            connectPlansdb()
            QueryDB(strSQL) 'does not exit function when done and goes through the function again

        End If

    End Using

End Function

The second problem I have is when I try to populate the list into a combo box in my form class where I call out to the database and use the returned list to populate my combo box. I can’t seem to figure out how to get the code to deal with the list.

    Private Sub cmbInvestmentStrategy_DropDown(sender As System.Object, e As System.EventArgs) Handles cmbInvestmentStrategy.DropDown

    Dim strat As New clsInvestmentStrategies()
    Dim invStrat As New List(Of String)

    invStrat = strat.getInvestmentStrategies() 'String cannot be converted to List(pf String)
    cmbInvestmentStrategy.Items.Add(invStrat) 'Error    3   Value of type 'System.Collections.Generic.List(Of String)' _
    'cannot be converted to '1-dimensional array of Object'.    

    End Sub

Any help would be greatly appreciated.

Thanks!

  • 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-05-28T23:39:28+00:00Added an answer on May 28, 2026 at 11:39 pm

    Your QueryDB method has a big flaw. If the database is unavailable (connectivity problems, database offline or wrong connection string), there will be an infinite loop. Your query DB method should just query the database. You could wrap it in another method responsible for connecting to the database, but you don’t want to retry database connection infinitely.

    As for your second method:

    invStrat = strat.getInvestmentStrategies() 'String cannot be converted to List(Of String)
    

    Error is pretty clear here. getInvestementStrategies returns a single String and cannot be converted to a list. It should return a List(Of String), or at least some collection of strings, I suppose?

    cmbInvestmentStrategy.Items.Add(invStrat) 'Error    3   Value of type 'System.Collections.Generic.List(Of String)' _
    'cannot be converted to '1-dimensional array of Object'.
    

    Items.Add will add a single element to the combobox. You should loop through the invStrat values, and call Add for every item. Alternatively, you could use the AddRange method, but this method expects an Array, not a List.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code which reads in the follow file, append a \r\n
i have the follow code: searchResults.SearchResultCollection.Add( new SearchResult() { Header = HttpUtility.HtmlDecode( htmlDocument.DocumentNode .SelectSingleNode(initialXPath
Follow up to this question . I have the following code: string[] names =
I have 3 different jquery uses & put it into one code as follows:
Is there a way to follow a program's execution through DLL code in hex?
I try to follow http://edn.embarcadero.com/article/28604 for restarting Interbase. Here is some code: program IBRestart;
Follow up to This I have also read up on some other questions but
Let's say I have a java program that makes an HTTP request on a
I follow this sample http://trac.osgeo.org/proj/wiki/ProjAPI but if I try to import this code in
I have a simple OpenGL program and trying to draw an instanced array that

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.