- 分享
- 0
- 人气
- 0
- 主题
- 2
- 帖子
- 269
- UID
- 270819
- 积分
- 188
- 阅读权限
- 13
- 注册时间
- 2009-10-15
- 最后登录
- 2013-9-30
- 在线时间
- 154 小时
|
本帖最后由 Kinni 于 2013-3-26 02:43 PM 编辑
suki89 发表于 2013-3-26 02:15 PM
因为你delete record过后没有message任何东西,database里的record被delete了是吗?
其实Full Code是这样的!对不起。。。一开始没有写完
Dim DBCon As OleDbConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Kini\Documents\Visual Studio 2010\Projects\WindowsApplication1\WindowsApplication1\bin\Debug\VB.accdb")
DBCon.Open()
Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM Staff WHERE StaffID ='" & txtStaffID.Text & "' and Password = '" & txtPass.Text & "' and UserFirstName= '" & txtFN.Text & "' and UserLastName= '" & txtLN.Text & "'", DBCon)
Dim sdr As OleDbDataReader = cmd.ExecuteReader()
If (sdr.Read() = False) Then
MessageBox.Show("Record not found!", "System Information")
DBCon.Close()
sdr.Close()
ElseIf (sdr.Read() = True) Then
sdr.Close()
Dim cmd2 As New OleDbCommand
cmd2.CommandText = "DELETE * FROM Staff WHERE StaffID='" & txtStaffID.Text & "'and Password='" & txtPass.Text & "'and UserFirstName='" & txtFN.Text & "'and UserLastname='" & txtLN.Text & "'"
cmd2.CommandText = CommandType.Text
cmd2.ExecuteNonQuery()
DBCon.Close()
valid6 = True
End If
End If
If valid6 = True Then
MessageBox.Show("Record has been deleted!", "System Information")
txtStaffID.Text = ""
txtPass.Text = ""
txtFN.Text = ""
txtLN.Text = ""
Else
MessageBox.Show("Delete record has been rejected", "System Information")
End If
我开了Database...并没有被删除~其实If statement应该没有什么问题吧?为什么进入不到True Statement but False 可以? |
|