当前位置:编程学习 > VB >>

vb修改数据库

If DTP1.Value = Enabled Then
cn.Execute "UPDATE khgl SET 来电时间 =  '" & DTP1.Value & "'"
Else
cn.Execute " UPDATE khgl SET 来电时间 = null"
End If
If DTP2.Value = Enabled Then
cn.Execute "UPDATE khgl SET 去电时间 =  '" & DTP1.Value & "'"
Else
cn.Execute " UPDATE khgl SET 去电时间 = null"
End If
cn.Execute "UPDATE khgl SET 公司名称 =text1.text"
cn.Execute "UPDATE khgl SET 客户区域 =text2.text "
cn.Execute "UPDATE khgl SET 联系人 =  text3.text  "
cn.Execute "UPDATE khgl SET 联系电话 = text4.text"
cn.Execute "UPDATE khgl SET 产品 =  text5.text"
cn.Execute "UPDATE khgl SET 认证类型  = text6.text"
cn.Execute "UPDATE khgl SET 客户问题 =  text7.text"
cn.Execute "UPDATE khgl SET 销售代表 =  combo1.text"
cn.Execute "UPDATE khgl SET 跟踪进展1 =  text8.text"
cn.Execute "UPDATE khgl SET 跟踪进展2 =  text15.text"
cn.Execute "UPDATE khgl SET 跟踪进展3 = text16.text"
cn.Execute "UPDATE khgl SET 当时回复 = combo2.text"
cn.Execute "UPDATE khgl SET 业务部门 = combo3.text"
cn.Execute "UPDATE khgl SET 客户分类= combo4.text"
If DTP3.Value = Enabled Then
cn.Execute "UPDATE khgl SET 询价时间 =  '" & DTP3.Value & "'"
Else
cn.Execute " UPDATE khgl SET 询价时间 = null"
End If
cn.Execute "UPDATE khgl SET 报价人= combo5.text"
cn.Execute "UPDATE khgl SET 报价时效= combo6.text"
If DTP4.Value = Enabled Then
cn.Execute "UPDATE khgl SET 下次联系时间 = '" & DTP4.Value & "'"
Else
cn.Execute " UPDATE khgl SET 下次联系时间 = null"
End If
cn.Execute "UPDATE khgl SET 备注跟踪情况=text9.text"
cn.Execute "UPDATE khgl SET 最终结果=text10.text"
cn.Execute "UPDATE khgl SET 原因分析=text11.text"
cn.Execute "UPDATE khgl SET 改进建议=text12.text"
cn.Execute "UPDATE khgl SET 备注 =text13.text"
以上代码无法更新数据库,望高手指点!! --------------------编程问答-------------------- strsql=" update 表名 set 字符型字段='"& 字符型变量 &"',数值型字段="& 数值型变量 &""
--------------------编程问答-------------------- 谢谢,怎么取得MSHFlexGrid1中的ID呢,ID是第一列! --------------------编程问答--------------------
'显示控件当前行第一列
msgbox mshflexgrid.textmatrix(mshflexgrid.row,0)
--------------------编程问答-------------------- where id=frm_xxxg.MSHFlexGrid1.TextMatrix(MSHFlexGrid1.row,0)还是修改了所有的行,还有日期存入了可以清空,但是清空了就无法保存了,日期采用dtpicker控件和check来控制的!
Private Sub Check1_Click()
If Check1.Value = 1 Then
DTP1.Enabled = True
Else
DTP1.Enabled = False
End If
End Sub
Private Sub Check2_Click()
If Check2.Value = 1 Then
DTP2.Enabled = True
Else
DTP2.Enabled = False
End If
End Sub
Private Sub Check3_Click()
If Check3.Value = 1 Then
DTP3.Enabled = True
Else
DTP3.Enabled = False
End If
End Sub
Private Sub Check4_Click()
If Check4.Value = 1 Then
DTP4.Enabled = True
Else
DTP4.Enabled = False
End If
End Sub
--------------------编程问答-------------------- 你的代码问题很多,如
cn.Execute "UPDATE khgl SET 公司名称 =text1.text" 
有2处错误:
1. 变量需要这样用
cn.Execute "UPDATE khgl SET 公司名称 ='" & text1.text &"'"
2. 一般要有where 条件,否则是全部更新为text1.text的值
cn.Execute "UPDATE khgl SET 公司名称 ='" & text1.text & "' where id=1"
3. 一次更新多个字段,可以这样写
cn.Execute "UPDATE khgl SET 公司名称 ='" & text1.text &"',联系人='" & text3.text & "' where id=1"
4. 日期字段可以为空,但日期控件的值不能为空
--------------------编程问答-------------------- http://download.csdn.net/source/1644211
补充:VB ,  数据库(包含打印,安装,报表)
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,