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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:42:47+00:00 2026-05-30T16:42:47+00:00

I have a datatable with some rows I need to insert that datatable in

  • 0

I have a datatable with some rows I need to insert that datatable in to database using a stored procedure.

 For Each row As DataRow In dt.Rows
            cmd.Parameters.Add(New MySqlParameter("@DOWNLOAD_ID", dt.Rows(0)("DOWNLOAD_ID").ToString()))
            cmd.Parameters.Add(New MySqlParameter("@FINALY_FIELDCODE", dt.Rows(0)("FINALY_FIELDCODE").ToString().Replace("|", "").ToString()))
            cmd.Parameters.Add(New MySqlParameter("@UNITS", dt.Rows(0)("UNITS").ToString()))
            cmd.Parameters.Add(New MySqlParameter("@CURRECY_CODE", dt.Rows(0)("CURRENCY_CODE").ToString()))
        Next
        cmd.ExecuteNonQuery()

When i do this I got an exception {"Parameter '@DOWNLOAD_ID' has already been defined."} How to get rid of this exception and can we insert the datatable with out for loop.
Can any one help me

  • 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-30T16:42:48+00:00Added an answer on May 30, 2026 at 4:42 pm

    You should create separate MySqlCommands and execute them directly:

    Using mysqlConnection = New MySqlConnection(connectionString)
        mysqlConnection.Open()
        For Each row As DataRow In dt.Rows
            Using cmd = New MySqlCommand("StoredProcedureName", mysqlConnection)
                cmd.CommandType = CommandType.StoredProcedure
                cmd.Parameters.Add(New MySqlParameter("@DOWNLOAD_ID", dt.Rows(0)("DOWNLOAD_ID").ToString()))
                cmd.Parameters.Add(New MySqlParameter("@FINALY_FIELDCODE", dt.Rows(0)("FINALY_FIELDCODE").ToString().Replace("|", "").ToString()))
                cmd.Parameters.Add(New MySqlParameter("@UNITS", dt.Rows(0)("UNITS").ToString()))
                cmd.Parameters.Add(New MySqlParameter("@CURRECY_CODE", dt.Rows(0)("CURRENCY_CODE").ToString()))
                cmd.ExecuteNonQuery()
            End Using
        Next
    End Using
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataTable which has some rows and I am using the select
I have a datatable which contains 10 rows. I now need to insert 11th
I have to delete some rows from a data table. I've heard that it
I'm using Visual Studio 2005 and have a DataTable with two columns and some
I have datatable with column name tag and 100 rows of data.I need to
I have a DataTable that has a boolean column called [Invalid]. I need to
I have some JSF code that currently works (as shown below), and I need
How to skip some rows to be displayed using dataTable: <h:dataTable cellspacing=0 id=dogs value=#{dogBean.dogs}
I need some help with a linq query. Basically, I have a datatable with
I have four DB tables in an Oracle database that need to be rewritten/refreshed

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.