下面是我做的一个小系统
Private Sub Command1_Click()
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim str As String
con.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=酒店房间管理系统;Data Source=HESHCH\SQLEXPRESS"
str = "select * from 房间信息 where 房间号='" & Trim(Text1.Text) & "'"
rs.Open str, con, 1, 1
If rs.EOF = True Then
MsgBox "无此未住人房间"
Text1.Text = ""
Text1.SetFocus
Else
If Trim(rs.Fields(3).Value) = 有 Then
MsgBox "此房间已经有人入住"
Else
con.Execute ("delete from 未入住人房间信息 where 房间号='" & Trim(Text1.Text) & "'")
con.Execute ("update 房间信息 set 是否有人入住='有',入住人姓名='" & Trim(Text2.Text) & " ',证件号码='" & Trim(Text3.Text) & " ' where 房间号='" & Trim(Text1.Text) & "'")
MsgBox "预订成功"
End If
End If
End Sub
但下面这段时候,Trim(rs.fields(3).value) 无论怎么改都是只会传去 else
If Trim(rs.Fields(3).Value) = 有 Then
MsgBox "此房间已经有人入住"
Else
con.Execute ("delete from 未入住人房间信息 where 房间号='" & Trim(Text1.Text) & "'")
con.Execute ("update 房间信息 set 是否有人入住='有',入住人姓名='" & Trim(Text2.Text) & " ',证件号码='" & Trim(Text3.Text) & " ' where 房间号='" & Trim(Text1.Text) & "'")
MsgBox "预订成功"
End If
求助,谢谢
Private Sub Command1_Click()
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim str As String
con.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=酒店房间管理系统;Data Source=HESHCH\SQLEXPRESS"
str = "select * from 房间信息 where 房间号='" & Trim(Text1.Text) & "'"
rs.Open str, con, 1, 1
If rs.EOF = True Then
MsgBox "无此未住人房间"
Text1.Text = ""
Text1.SetFocus
Else
If Trim(rs.Fields(3).Value) = 有 Then
MsgBox "此房间已经有人入住"
Else
con.Execute ("delete from 未入住人房间信息 where 房间号='" & Trim(Text1.Text) & "'")
con.Execute ("update 房间信息 set 是否有人入住='有',入住人姓名='" & Trim(Text2.Text) & " ',证件号码='" & Trim(Text3.Text) & " ' where 房间号='" & Trim(Text1.Text) & "'")
MsgBox "预订成功"
End If
End If
End Sub
但下面这段时候,Trim(rs.fields(3).value) 无论怎么改都是只会传去 else
If Trim(rs.Fields(3).Value) = 有 Then
MsgBox "此房间已经有人入住"
Else
con.Execute ("delete from 未入住人房间信息 where 房间号='" & Trim(Text1.Text) & "'")
con.Execute ("update 房间信息 set 是否有人入住='有',入住人姓名='" & Trim(Text2.Text) & " ',证件号码='" & Trim(Text3.Text) & " ' where 房间号='" & Trim(Text1.Text) & "'")
MsgBox "预订成功"
End If
求助,谢谢