当数据数量达到限制时,如何防止用户插入相同的数据?
我正在为我的项目使用vb.net和SQL。我为我的问题提供了一个情况:
表数量
id Pro_no Quantity
1 123 4
2 456 5
表insertdata
id Pro_no Quantity Description
1 123 2 broken
2 123 1 missing part
,您可以看到用户插入了pro_no
123
in insertdata表
。这意味着它具有1
更多数量
可以插入。我的问题是,当有2个用户或用户打开具有2个选项卡的相同数据时,想要同时插入数据时,其中一个或其中一个选项卡将无法成功执行此操作,因为它已经达到了极限。
sql:
INSERT INTO insertData (Pro_no, Quantity,Description)
VALUES ('123','1','broken')
vb.net
Protected Sub btnCreate_Click(sender As Object, e As EventArgs) Handles btnCreate.Click
If ErrorChecking() = True Then
DataInsert()
DisplayMessage("success", "Done", "Data Succesfully Inserted!")
clearAll()
End If
End Sub
datainsert()函数:
Private Function DataInsert() As Integer
Using create As New clsQuantityProject_dal
Dim obj As New clsQuantityProject_info
With obj
.Part_No = txtPartNo.Text
.Description = txtDesc.Text
.QTY = spinEditQTY.Text
End With
Dim strResult As Integer = create.QuantityDataInsert(obj)
End Using
Return 1
End Function
注意:请告诉我,如果您无法理解我的问题,我会纠正并更好地解释它
I'm using VB.net and SQL for my project. I give a situation for my problem:
Table Quantity
id Pro_no Quantity
1 123 4
2 456 5
Table insertData
id Pro_no Quantity Description
1 123 2 broken
2 123 1 missing part
As you can see user has inserted Pro_no
for 123
into the insertData table
. Meaning that it has 1
more Quantity
can be inserted. My problem is when there are 2 users OR user open the same data with 2 tabs, want to insert the data at the same time, one of them OR one of the tab will not successful to do it cause it has reached the limit.
SQL :
INSERT INTO insertData (Pro_no, Quantity,Description)
VALUES ('123','1','broken')
VB.net
Protected Sub btnCreate_Click(sender As Object, e As EventArgs) Handles btnCreate.Click
If ErrorChecking() = True Then
DataInsert()
DisplayMessage("success", "Done", "Data Succesfully Inserted!")
clearAll()
End If
End Sub
DataInsert() Function :
Private Function DataInsert() As Integer
Using create As New clsQuantityProject_dal
Dim obj As New clsQuantityProject_info
With obj
.Part_No = txtPartNo.Text
.Description = txtDesc.Text
.QTY = spinEditQTY.Text
End With
Dim strResult As Integer = create.QuantityDataInsert(obj)
End Using
Return 1
End Function
note: do tell me if you can't understand my question, I'll correct and explain it better
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论