表中两次数据存储 [英] two time data store in table
本文介绍了表中两次数据存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的问题是,当我单击btnupload时,两次数据存储在表中.
我的代码是:
Hi,
My problem is when I click on btnupload then, two times data is stored in table.
My code is:
Protected Sub btnupload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnupload.Click
imagename = imgupload.FileName
fileExt = System.IO.Path.GetExtension(imgupload.FileName).ToLower
If (fileExt = ".jpg" Or fileExt = ".gif" Or fileExt = ".bmp" Or fileExt = ".jpeg" Or fileExt = ".png") Then
Label1.Visible = True
imgupload.SaveAs(Server.MapPath("~/Images/" + imagename))
Label1.Text = imagename + " is uploaded sucessfully"
ipath = ("Images")
'u.insertImgData(ipath, imagename, fileExt)
Call save()
Dim displaypath As String = "~/Images/" + imagename
uploadedimg.ImageUrl = displaypath
Else
Label1.Visible = True
Label1.Text = "Invalid extension"
End If
End Sub
Private Sub save()
con.Close()
Dim ss As String
con.Open()
ss = "insert into imgData values('" & ipath & "','" & imagename & "','" & fileExt & "')"
cmd = New SqlCommand(ss, con)
cmd.ExecuteNonQuery()
con.Close()
End Sub
推荐答案
- 在以下函数上设置断点
- Put break point on following function
Private Sub save()
count(*) from imgData
这意味着您可能定义了两个处理程序(或在两个不同位置添加的同一处理程序)来处理点击事件-我会首先检查我是否是你.
That implies that you may have two handlers (or the same handler added in two different places) defined to handle the click event - I''d check that first if I was you.
您两次未执行代码,请检查它……并运行应用程序.您应该创建一个autoid函数.用于将数据存储在数据库中.
Your Not Executing the code two times please check it...... and run the appliaction.You should create one autoid function.for storing the data in database.
这篇关于表中两次数据存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文