Bug #33959 CONNECTOR DUPLICATE ENTRIES IN ASP .NET
| Submitted: | 21 Jan 2008 16:31 | Modified: | 29 Jan 2008 19:28 |
|---|---|---|---|
| Reporter: | Jorge Aceves | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | Connector / NET | Severity: | S3 (Non-critical) |
| Version: | 5.0 | OS: | Windows (Windows Vista) |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | asp.net, connector, duplicate, ENTRIES | ||
[21 Jan 2008 16:31]
Jorge Aceves
[22 Jan 2008 7:04]
Jorge Aceves
This is the code that produces the error:
This is the code that creates a duplicate entry of the record.
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim StrFilename As String
StrFilename = File1.PostedFile.FileName
StrFilename = System.IO.Path.GetFileName(StrFilename)
File1.PostedFile.SaveAs(Server.MapPath("~/images/") + StrFilename)
Dim File As String
File = "~/images/" + StrFilename
'Conexión BD - Mysql connector
Dim Conexion = New MySqlConnection
Try
Conexion = New MySqlConnection("Data Source=localhost;Initial Catalog=imagenes; User ID=root; PWD=1234;")
Conexion.open()
Catch myerror As MySqlException
MsgBox("Connectivity Error: " & myerror.Message)
End Try
'Save Record
Dim com As New MySqlCommand
com.Connection = Conexion
com.CommandText = "insert into path (Imagen) values (?imagen)"
com.Parameters.AddWithValue("?imagen", Archivo)
com.ExecuteNonQuery()
'Fin de Conexion
Try
Dim number
number = com.ExecuteNonQuery()
Catch ex As Exception
'Send to another page explaining there was an error with the transaction
Finally
End Try
Conexion.close()
Conexion = Nothing
com = Nothing
End Sub
[29 Jan 2008 17:33]
Reggie Burnett
Your code is calling ExecuteNonQuery twice. This will cause two records to be inserted (assuming no pk conflict)
[29 Jan 2008 19:28]
Jorge Aceves
Thank you very much, I didnt noticed that I was executing the query twice, I tried to look for something that was repeated, but maybe because of the frustration I didnt see it. Thank you very much. And sorry for wasting your time. Sinceraly Jorge
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.051 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.