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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:39:07+00:00 2026-05-23T03:39:07+00:00

I have a bit of a strange problem with MySQL that I’ve never seen

  • 0

I have a bit of a strange problem with MySQL that I’ve never seen before. Basically, I need to enter the same entry into a table x number of times. The Primary Key is auto increment so there shouldn’t be any duplicate value problems. However, it takes the last few columns and seems to clump them all into one value and is using that as a key. The error I’m getting back is:

    Duplicate entry '80-0--2011-06-16-0-1' for key 'idx_mt'

Mind you, there is no field called idx_mt. The primary key field is called just ID. And that 80-0–2011-06-16-0-1 is the last 8 columns or so (which you can see the names of in the cols variable) concatenated, which they obviously shouldn’t be doing. Also, the first time the loop runs through, the entry goes through, but the later ones conflict with it. I confirmed that this is the problem by changing one of the last 8 columns to a value based on a loop, and that went through with no problems. Any insight?

    Dim cols As String = ""
    Dim msi As System.Globalization.DateTimeFormatInfo = New System.Globalization.DateTimeFormatInfo()

    cols = "TEMPLATE_NAME," & _
           "DESCRIPTION," & _
           "FORMAT," & _
           "SENDER," & _
           "`REPLY-TO`," & _
           "SUBJECT," & _
           "BODYHTML," & _
           "BODYTEXT," & _
           "CAMPAIGN_ID," & _
           "SPLIT_GROUP_ID," & _
           "TEMPLATE_IDENTIFIER," & _
           "MESSAGE_SEND_DATE," & _
           "DAYS_TO_DELAY_SEND," & _
           "ACTIVE"

    Try
        Dim test As Integer = CInt(cmbEffort.Text)
    Catch ex As Exception
        MsgBox("Please use numerical values from 1 - 6 for the effort #.")
        Return
    End Try

    If (cmbEffort.Text < 1 Or cmbEffort.Text > 6) Then
        MsgBox("Please use numerical values from 1 - 6 for the effort #.")
        Return
    End If

    Dim query As String = ""
    Dim _date As Date = DateTimePicker1.Value
    Dim dateSent As String = ""
    Dim html As String = ""
    Dim temp As message

    If (_date.DayOfWeek <> DayOfWeek.Thursday) Then
        MsgBox("Selected date must be a Thursday.")
        Return
    End If

    dateSent = formatDate(_date)

    Try
        fileStreamIn = New IO.FileStream(txtHTML.Text, IO.FileMode.Open)
        streamReader = New IO.StreamReader(fileStreamIn)
    Catch ex As Exception
        MsgBox("HTML File not found.")
        Return
    End Try

    html = streamReader.ReadToEnd()
    html = html.Replace("'", "&apos")

    streamReader.Close()

    server.query("SELECT * FROM TEMPLATES_TO_COPY WHERE CAMPAIGN_ID = " & cmpgnID)
    server.read()

    temp = getMessage(cmpgnID.ToString())
    temp.bodyText = txtMessage.Text
    temp.HTML = html
    temp.sendDate = dateSent
    temp.description = txtDescription.Text & "_" & cmbEffort.Text
    temp.campaignID = cmpgnID
    temp.name = temp.name.Replace("MMM", msi.GetMonthName(_date.Month).Substring(0, 3).ToUpper())
    temp.name = temp.name.Replace("YY", _date.Year.ToString().Substring(2, 2))

    For i As Integer = 1 To cmbEffort.Text
        temp.name = temp.name.Replace("X", (i + 1).ToString())
        query = "INSERT INTO MESSAGE_TEMPLATES (" & _
                cols & ")" & _
                "VALUES ('" & temp.name & "','" & temp.description & "','" & temp.format & "','" & temp.sender & "','" & temp.replyTo & "','" & temp.subject & "','" & temp.HTML & "','" & temp.bodyText & "'," & temp.campaignID & "," & 0 & ",'','" & temp.sendDate & "'," & temp.daysToDelay & "," & temp.active & ");"

        If (Not server.query(query)) Then
            Return
        End If
        temp.name = temp.name.Replace((i + 1).ToString(), "X")
    Next
  • 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-23T03:39:08+00:00Added an answer on May 23, 2026 at 3:39 am

    The error is precisely what it says it is:

     Duplicate entry '80-0--2011-06-16-0-1' for key 'idx_mt'
    

    There is a key/index that you have defined called idx_mt. This key is set up among a handful of columns. As others have pointed out in the comments, the values of all of those columns together are identical to a row already in your table, thus causing this conflict.

    The duplicate entry with the fields concatenated together is how MySQL displays the value (and maybe even stores, I’m not sure) for that key. It keeps track of it essentially like another column. The values that are put there are made up of other columns in the table.

    When you see 80-0--2011-06-16-0-1, it means that the fields in this index on this particular row have the values of 80, 0, null, 2011-06-16, 0, and 1. What you INSERT is conflicting with that.

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

Sidebar

Related Questions

I have a bit of a strange problem. I have a controller that is
I have a bit of strange problem on this page: http://www.bluprintliving.com/locations it seems that
I have a bit of a strange problem. I am trying to send in-app
I have a feeling my problem is a bit strange, but here goes... I
This a bit of strange one.... We have an internal web app that runs
I have bit of a strange problem. In have a MovieClip i resize, but
I'm a bit newbie to Flash, and I'm experiencing strange problem. I have a
I have a bit of a strange problem, please examine the following SQL CREATE
I have a strange problem. I have a project that I have that simply
Right, bit of a strange question; I have been doing some linq to XML

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.