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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:45:52+00:00 2026-06-05T17:45:52+00:00

In short I am writing a class handler to handle to database integration of

  • 0

In short I am writing a class handler to handle to database integration of some software I am writing for myself, however as there is not always a connection to the remote database I thought I would use SQLCE to create a local database buffer so when a connection is made the changes can be synchronized.

So far it is going well except for the parameters. The function I am looking to call is shown below however this function is complaining about invalid arguments.

public Object run(string query, List<Object> dbparams = null)
    {
        if (MyDB.isConnected())
        {
            return MyDB.run(query, dbparams);
        }
        else
        {
            SqlCeCommand sql = _OfflineConnection.CreateCommand();
            sql.CommandText = query;
            if (dbparams.Count > 0)
            {
                sql.Parameters.AddRange(dbparams.ToArray());
            }
            return sql;
        }
    }

MyDB.run is the exact same code as in the else statement except for mysql, the line that it is moaning about is the return mydb.run as the mydb class is expecting the dbparams list to be of mysqlparameters.

Does anyone know how I can achieve this? I attempted to use LINQ to do a convert but that failed miserably.

EDIT

At present I have the following working but I am sure there is a cleaner solution

public Object run(string query, List<Object> dbparams = null)
    {
        if (MyDB.isConnected())
        {
            List<MySqlParameter> mydbparams = null;
            for (int i = 0; i < dbparams.Count; i++)
            {
                mydbparams.Add((MySqlParameter)dbparams[i]);
            }
            return MyDB.run(query, mydbparams);
        }
        else
        {
            SqlCeCommand sql = _OfflineConnection.CreateCommand();
            sql.CommandText = query;
            if (dbparams.Count > 0)
            {
                sql.Parameters.AddRange(dbparams.ToArray());
            }
            return sql;
        }
    }
  • 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-05T17:45:54+00:00Added an answer on June 5, 2026 at 5:45 pm

    A bit cleaner solution would be

    mydbparams = dbparams.Cast<MySqlParameters>().ToList();
    

    Also, you should check for and handle the null condition of dbparams.

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

Sidebar

Related Questions

I'm writing a short class to extract email addresses from documents. Here is my
I'm currently writing a generic vector template class (the geometric entity, not the container)
This is my sever require 'rubygems' require 'benchmark' require 'eventmachine' class Handler < EventMachine::Connection
Scala programmer should have known that this sort of writing : class Person{ var
Short of writing a function manually that translates a few known REFIID to names,
So, I am writing a short (and simple) regular expression, but I can think
I am writing a function short getBits(short data, int p, int n) I have
I'm writing an asp.net server side control which has a few short parameters passed
I'm writing a messaging layer that should handle communication with a third party API.
i'm currently writing on some piece of code in android 2.1 that is supposed

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.