关于vb属性的使用无效的问题
时间:2011-12-22
来源:互联网
这是调用数据库并向数据库插入内容的代码
Private Sub Form_Load()
On Error Resume Next
Dim provider As String
provider = "Provider = SQLOLEDB.1"
datasource = "User ID=sa;PWD=;Data Source=PC-201111082239\ZJW;Initial Catalog=客户数据管理"
With Adodc1
.Mode = adModeReadWrite
.ConnectionString = provider & ";" & datasource
.CommandType = adCmdTable
.RecordSource = "联系记录表"
.Refresh
End With
End Sub
Private Sub Command1_Click()
With Adodc1
.Recordset AddNew
.Recordset.Fields(0).Value = Text1.Text
.Recordset.Fields(1).Value = Text2.Text
.Recordset.Fields(2).Value = Text3.Text
.Recordset.Fields(3).Value = Text4.Text
.Recordset.Fields(4).Value = Text5.Text
.Recordset.Fields(5).Value = Text6.Text
.Recordset.Fields(6).Value = Text7.Text
.Recordset.Update
End With
Set main.DataGrid1.datasource = Adodc1
End Sub
运行后单击按钮一直出现命令的使用无效 单击确定在command1_click事件显示那个黄色提示
求大神帮解决
Private Sub Form_Load()
On Error Resume Next
Dim provider As String
provider = "Provider = SQLOLEDB.1"
datasource = "User ID=sa;PWD=;Data Source=PC-201111082239\ZJW;Initial Catalog=客户数据管理"
With Adodc1
.Mode = adModeReadWrite
.ConnectionString = provider & ";" & datasource
.CommandType = adCmdTable
.RecordSource = "联系记录表"
.Refresh
End With
End Sub
Private Sub Command1_Click()
With Adodc1
.Recordset AddNew
.Recordset.Fields(0).Value = Text1.Text
.Recordset.Fields(1).Value = Text2.Text
.Recordset.Fields(2).Value = Text3.Text
.Recordset.Fields(3).Value = Text4.Text
.Recordset.Fields(4).Value = Text5.Text
.Recordset.Fields(5).Value = Text6.Text
.Recordset.Fields(6).Value = Text7.Text
.Recordset.Update
End With
Set main.DataGrid1.datasource = Adodc1
End Sub
运行后单击按钮一直出现命令的使用无效 单击确定在command1_click事件显示那个黄色提示
求大神帮解决
作者: zjw9527007 发布时间: 2011-12-22
VB code
Private Sub Form_Load() On Error Resume Next Dim provider As String provider = "Provider = SQLOLEDB.1" datasource = "User ID=sa;PWD=;Data Source=PC-201111082239\ZJW;Initial Catalog=客户数据管理" With Adodc1 .Mode = adModeReadWrite .ConnectionString = provider & ";" & datasource .CommandType = adCmdTable .RecordSource = "联系记录表" .Refresh End With End Sub Private Sub Command1_Click() With Adodc1 .Recordset AddNew .Recordset.Fields(0).Value = Text1.Text .Recordset.Fields(1).Value = Text2.Text .Recordset.Fields(2).Value = Text3.Text .Recordset.Fields(3).Value = Text4.Text .Recordset.Fields(4).Value = Text5.Text .Recordset.Fields(5).Value = Text6.Text .Recordset.Fields(6).Value = Text7.Text .Recordset.Update End With [color=#FF0000]call form_load[/color] End Sub
作者: woodepany 发布时间: 2011-12-22
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28