vb datagrid 内容添加上之后不显示
添加正常,但是就是不显示。ps:我是在已成功运行的例子上添加的一个窗体,按钮命令都正常,只是不能显示。求大神指点!不胜感激用的是SQLSERVER2000的数据库Priv...
添加正常,但是就是不显示。ps:我是在已成功运行的例子上添加的一个窗体,按钮命令都正常,只是不能显示。求大神指点!不胜感激 用的是SQL SERVER 2000的数据库
Private Sub Form_Load()
On Error GoTo Err1
Sql = "select id=(max(topicid)+1) from tb_topicstor where typeid=3"
With Ado
.Visible = False
.ConnectionString = cnn.ConnectionString
.CommandType = adCmdText
.RecordSource = Sql
.Refresh
End With
Txt_Name.Text = ""
Txt_Answer.Text = "" ‘这六个的datasource = ado
Txt_A.Text = ""
Txt_B.Text = ""
Txt_C.Text = ""
Txt_D.Text = ""
Exit Sub
Err1:
ErrMessageBox "窗口打开失败"
Unload Me
frm_Manager.Show
End Sub
Private Sub Cmd_Ok_Click() ’保存添加的记录
rs1.Open "select * from tb_topicstor", cnn, adOpenKeyset, adLockOptimistic
rs1.AddNew '添加新记录
rs1.Fields("TYPEID") = 3
rs1.Fields("Topicid") = val(Txt_id.Text)
rs1.Fields("Topicname") = Txt_Name.Text
rs1.Fields("Topicanswer") = Txt_Answer.Text
rs1.Fields("A") = Txt_A.Text
rs1.Fields("B") = Txt_B.Text
rs1.Fields("C") = Txt_C.Text
rs1.Fields("D") = Txt_D.Text
rs1.Update '保存记录
rs1.Close '关闭数据集对象
MsgBox "恭喜您,添加成功!", vbOKCancel + vbInforma 展开
Private Sub Form_Load()
On Error GoTo Err1
Sql = "select id=(max(topicid)+1) from tb_topicstor where typeid=3"
With Ado
.Visible = False
.ConnectionString = cnn.ConnectionString
.CommandType = adCmdText
.RecordSource = Sql
.Refresh
End With
Txt_Name.Text = ""
Txt_Answer.Text = "" ‘这六个的datasource = ado
Txt_A.Text = ""
Txt_B.Text = ""
Txt_C.Text = ""
Txt_D.Text = ""
Exit Sub
Err1:
ErrMessageBox "窗口打开失败"
Unload Me
frm_Manager.Show
End Sub
Private Sub Cmd_Ok_Click() ’保存添加的记录
rs1.Open "select * from tb_topicstor", cnn, adOpenKeyset, adLockOptimistic
rs1.AddNew '添加新记录
rs1.Fields("TYPEID") = 3
rs1.Fields("Topicid") = val(Txt_id.Text)
rs1.Fields("Topicname") = Txt_Name.Text
rs1.Fields("Topicanswer") = Txt_Answer.Text
rs1.Fields("A") = Txt_A.Text
rs1.Fields("B") = Txt_B.Text
rs1.Fields("C") = Txt_C.Text
rs1.Fields("D") = Txt_D.Text
rs1.Update '保存记录
rs1.Close '关闭数据集对象
MsgBox "恭喜您,添加成功!", vbOKCancel + vbInforma 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询