VB向数据库中添加字段问题
Dimshili(100)PrivateSubCommand1_Click()Adodc1.CommandType=adCmdTextAdodc1.RecordSourc...
Dim shili(100)
Private Sub Command1_Click()
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from 人物信息 where 人物名字 = '" & Trim(Text1.Text) & "'"
Adodc1.Refresh
If Text1.Text = "" Then
MsgBox "请输入武将姓名", , "添加武将"
Text1.SetFocus
Exit Sub
End If
If Adodc1.Recordset.EOF = False Then
MsgBox "武将已存在,无法输入", , "添加武将"
Else
Select Case Option1.Value
Case Is = 1
Adodc1.Refresh
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("性别") = "男"
Adodc1.Recordset.Fields("人物名字") = Text1.Text
Adodc1.Recordset.Fields("籍贯") = Text2.Text
Adodc1.Recordset.Fields("人物简介") = Text3.Text
Adodc1.Recordset.Fields("势力") = Combo1.Text
Adodc1.Recordset.Update
Adodc1.Recordset.Close
MsgBox "添加成功", , "恭喜"
Unload Form4
Case Is = 0
Adodc1.Refresh
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("性别") = "女"
Adodc1.Recordset.Fields("人物名字") = Text1.Text
Adodc1.Recordset.Fields("籍贯") = Text2.Text
Adodc1.Recordset.Fields("人物简介") = Text3.Text
Adodc1.Recordset.Fields("势力") = Combo1.Text
Adodc1.Recordset.Update
Adodc1.Recordset.Close
MsgBox "添加成功", , "恭喜"
Unload Form4
MDIForm1.Show
End Select
End If
End Sub
Private Sub Command2_Click()
Unload Form4
MDIForm1.Show
End Sub
Private Sub Form_Load()
shili(1) = "吴国"
shili(2) = "魏国"
shili(3) = "蜀国"
shili(4) = "群雄"
For i = 1 To 4
Combo1.AddItem shili(i)
Next i
End Sub
VB提示说VB在对应所需的名称或序数的集合中,未找到该项目
Adodc1.Recordset.Fields("人物简介") = Text3.Text
Adodc1.Recordset.Fields("势力") = Combo1.Text
表中有这两个 展开
Private Sub Command1_Click()
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from 人物信息 where 人物名字 = '" & Trim(Text1.Text) & "'"
Adodc1.Refresh
If Text1.Text = "" Then
MsgBox "请输入武将姓名", , "添加武将"
Text1.SetFocus
Exit Sub
End If
If Adodc1.Recordset.EOF = False Then
MsgBox "武将已存在,无法输入", , "添加武将"
Else
Select Case Option1.Value
Case Is = 1
Adodc1.Refresh
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("性别") = "男"
Adodc1.Recordset.Fields("人物名字") = Text1.Text
Adodc1.Recordset.Fields("籍贯") = Text2.Text
Adodc1.Recordset.Fields("人物简介") = Text3.Text
Adodc1.Recordset.Fields("势力") = Combo1.Text
Adodc1.Recordset.Update
Adodc1.Recordset.Close
MsgBox "添加成功", , "恭喜"
Unload Form4
Case Is = 0
Adodc1.Refresh
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("性别") = "女"
Adodc1.Recordset.Fields("人物名字") = Text1.Text
Adodc1.Recordset.Fields("籍贯") = Text2.Text
Adodc1.Recordset.Fields("人物简介") = Text3.Text
Adodc1.Recordset.Fields("势力") = Combo1.Text
Adodc1.Recordset.Update
Adodc1.Recordset.Close
MsgBox "添加成功", , "恭喜"
Unload Form4
MDIForm1.Show
End Select
End If
End Sub
Private Sub Command2_Click()
Unload Form4
MDIForm1.Show
End Sub
Private Sub Form_Load()
shili(1) = "吴国"
shili(2) = "魏国"
shili(3) = "蜀国"
shili(4) = "群雄"
For i = 1 To 4
Combo1.AddItem shili(i)
Next i
End Sub
VB提示说VB在对应所需的名称或序数的集合中,未找到该项目
Adodc1.Recordset.Fields("人物简介") = Text3.Text
Adodc1.Recordset.Fields("势力") = Combo1.Text
表中有这两个 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询