- 分享
- 0
- 人气
- 0
- 主题
- 17
- 帖子
- 183
- UID
- 25887
- 积分
- 129
- 阅读权限
- 13
- 注册时间
- 2006-1-28
- 最后登录
- 2016-4-11
- 在线时间
- 476 小时
|
很急~VB TRY CATCH~END TRY 问题~
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
If txtID.Text <> "" Then
strsql = "insert into Table1 (stfID,staffname,staffage,staffadd,staffposition,staffsex,stafftime) values ('" _
& txtID.Text & "','" _
& txtName.Text & "','" _
& txtAge.Text & "','" _
& txtAddress.Text & "','" _
& txtPosition.Text & "','" _
& txtSex.Text & "','" _
& txtTime.Text & "')"
MsgBox("Saved")
Else
MsgBox("invalid", vbCritical)
End If
Dim acscmd As New OleDb.OleDbCommand
acscmd.CommandText = strsql
acscmd.Connection = acsconn
acsda.SelectCommand = acscmd
acsdr = acscmd.ExecuteReader
acscmd.ExecuteNonQuery()
acscmd.Dispose()
Me.filllistview()
End Sub
这是小弟的CODING
想请问下
如果要用TRY CATCH ENDTRY确保当同样的ID时不能被SAVE??
因为如果同样的ID SAVE了会有RUNTIME ERROR
请问要如何解决此问题呢?
谢谢 |
|