标题:关于写入SQL数据库的问题
只看楼主
wfox2001
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-6-26
 问题点数:0 回复次数:0 
关于写入SQL数据库的问题

小弟最近在搞毕业设计,遇到了困难,请各位大虾帮忙。
我把代码写在下面,具体的问题是这个模块写入数据时,在SQLs数据库中始终显示NULL,比如“房间号,价格,备注”,始终不明白为什么,请给位大虾给我指导一下。代码如下:


Private Sub Adodc1_WillMove(ByVal adReason As ADODB.EventReasonEnum, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)

End Sub

Private Sub DataGrid1_Click()

End Sub

Private Sub Form_Unload(Cancel As Integer)
main.Enabled = True
End Sub
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Combo2.SetFocus
If Adodc1.Recordset.RecordCount > 0 Then Texjg.Text = Adodc1.Recordset.Fields("价格")
End Sub

Private Sub texfjh_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Combo1.SetFocus '按回车键Combo1获得焦点
End Sub
Private Sub Combo2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Texjg.SetFocus
End Sub


Private Sub texbz_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Comsave.SetFocus
End Sub
Private Sub comdj_Click() '登记
Texfjh.Text = "": Texjg.Text = ""
Texbz.Text = ""
Comsave.Enabled = True: Comcancel.Enabled = True: Comdj.Enabled = False
Texfjh.SetFocus
End Sub
Private Sub comsave_Click()
'查找客房信息
Adodc1.RecordSource = "select * from kf where 房间号 like '" & Texfjh.Text & "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount = 0 Then
'添加客房
Adodc1.Recordset.AddNew
If Texfjh.Text <> "" Then Adodc1.Recordset.Fields("房间号") = Texfjh.Text
If Combo1.Text <> "" Then Adodc1.Recordset.Fields("房间类型") = Combo1.Text
If Combo2.Text <> "" Then Adodc1.Recordset.Fields("房态") = Combo2.Text
If Texjg.Text <> "" Then Adodc1.Recordset.Fields("价格") = Texjg.Text
If Check1.Value Then
Adodc1.Recordset.Fields("是否有电视") = "有"
Else
Adodc1.Recordset.Fields("是否有电视") = "无"
End If
If Check2.Value Then
Adodc1.Recordset.Fields("是否有空调") = "有"
Else
Adodc1.Recordset.Fields("是否有空调") = "无"
End If
If Texbz.Text <> "" Then Adodc1.Recordset.Fields("备注") = Texbz.Text
Adodc1.Recordset.Update '更新记录
Adodc1.Refresh
Else
'编辑客房信息
If Texfjh.Text <> "" Then Adodc1.Recordset.Fields("房间号") = Texfjh.Text
If Combo2.Text <> "" Then Adodc1.Recordset.Fields("房态") = Combo2.Text
If Combo1.Text <> "" Then Adodc1.Recordset.Fields("房间类型") = Combo1.Text
If Texjg.Text <> "" Then Adodc1.Recordset.Fields("价格") = Texjg.Text
If Check1.Value Then
Adodc1.Recordset.Fields("是否有电视") = "有"
Else
Adodc1.Recordset.Fields("是否有电视") = "无"
End If
If Check2.Value Then
Adodc1.Recordset.Fields("是否有空调") = "有"
Else
Adodc1.Recordset.Fields("是否有空调") = "无"
End If
If Texbz.Text <> "" Then Adodc1.Recordset.Fields("备注") = Texbz.Text
Adodc1.Recordset.Update '更新记录
Adodc1.Refresh
End If
Adodc1.RecordSource = "select * from kf where 房间号 like '" & Texfjh.Text & "'"
Adodc1.Refresh
Adodc2.RecordSource = "select * from djb where 房间号 like '" & Texfjh.Text & "' and (标志 like '入住' or 标志 like '预定')"
Adodc2.Refresh
If Adodc2.Recordset.RecordCount <> 0 Then
Adodc2.Recordset.Fields("标志") = Combo2.Text
Adodc2.Recordset.Update
End If
'设置控件有效或无效
Comsave.Enabled = False: Comcancel.Enabled = False
Comend.Enabled = True: Comdj.Enabled = True
End Sub
Private Sub comcancel_Click() '取消操作
Texfjh.Text = "": Texjg.Text = ""
Texbz.Text = ""
Comsave.Enabled = False: Comcancel.Enabled = False: Comdj.Enabled = True
End Sub
Private Sub comend_Click()
main.Enabled = True
Unload Me
End Sub

搜索更多相关主题的帖子: SQL 数据库 
2006-06-26 19:53



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-74983-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.104050 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved