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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:21:46+00:00 2026-06-10T21:21:46+00:00

I have an ODBC connection to a database of which I need one table

  • 0

I have an ODBC connection to a database of which I need one table of data. The table has about 20 rows, and a couple thousand lines of data.

I intend to insert this table into my local SQL Server CE database, where I can put it to further use. Both connections have been tested and work.

My attempt was at just inserting one column to keep things simple (I’m new to C#, programming, and stackoverflow).

OdbcConnection c = new OdbcConnection(ConnectionString1);
SqlCeConnection d = new SqlCeConnection(ConnectionString2);

c.Open();
d.Open();

string sqlC = "SELECT * FROM ODBCTABLE WHERE ODBCCOLUMN='12345'";
OdbcCommand commandC = new OdbcCommand(sqlC, c);

string sqlD = "INSERT INTO SQLCETABLE(SQLCECOLUMN) VALUES (@sql)";
SqlCeCommand commandD = new SqlCeCommand(sqlD, d);

OdbcDataReader reader = commandC.ExecuteReader();

while (reader.Read())
{
  string x = reader[0].ToString();                   
  commandD.Parameters.Add("@sql",SqlDbType.NVarChar, 5).Value = x;
  commandD.ExecuteNonQuery();     
}

c.Close();
c.Dispose();

d.Close();
d.Dispose();

I get the error The SqlCeParameter with this name is already contained by this SqlCeParameterCollection.

  1. Why is this wrong?
  2. Is there a way to fix this?
  3. Are there better ways to do this
    transfer? (I believe sqlbulktransfer does not exist for odbc)
  4. Being my first post on Stackoverflow, did I go about posting a
    question correctly?
  • 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-10T21:21:48+00:00Added an answer on June 10, 2026 at 9:21 pm

    Change this part of your code

    commandD.Parameters.Add("@sql",SqlDbType.NVarChar, 5); 
    while (reader.Read()) 
    { 
      string x = reader[0].ToString();                   
      commandD.Parameters["@sql"].Value = x ;
      commandD.ExecuteNonQuery();      
    } 
    

    The problem arises because, in every loop, you repeat the add of the same named parameter to the collection resulting in the error above.
    Moving the creation of the parameter outside the loop and updating only the value inside the loop should resolve the error.

    Yes, I think you have posted the question correctly.

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

Sidebar

Related Questions

I have one application in which I need to delete table if exit in
I have a method which is connecting to a database via Odbc. The stored
I have an Excel 2007 ODBC connection defined and I need to allow users
On the class level, I have created reference: System::Data::Odbc::OdbcConnection Connection; in some method I
I have a database in a format which can be accessed via ODBC. I'm
Is it possible to have an ODBC connection to a MS Access 2007 database
i have a mssql database and php connection via ODBC driver and system DSN
I have created an ODBC connection for oracle using Microsoft ODBC for Oracle driver
I have a pdo connection with ODBC (v2000.86.359.00) connecting to an SQL Server (v8.00.2039
I have a linked Firebird database on my SQL Server 2008 via ODBC. I

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.