VB中连接数据库和对数据库进行添加,修改,删除,显示的操作的问题
本人是个菜鸟,想学习一下怎样在VB中连接数据库,具体怎么操作,越详细越好,网上看过不少,可都不怎么明白,还有,怎么在界面上显示数据库中的内容,并且对其进行修改,添加,删除...
本人是个菜鸟,想学习一下怎样在VB中连接数据库,具体怎么操作,越详细越好,网上看过不少,可都不怎么明白,还有,怎么在界面上显示数据库中的内容,并且对其进行修改,添加,删除的操作?希望哪位大侠赐教一下,能把每句代码的中文意思都标注出来最好,谢谢了!对了,还有查询的功能,怎么样与数据库中进行比对?
望发到我邮箱中!!谢谢!小弟只有30分了,全部拿出来!
jinlei198561@yahoo.com.cn 展开
望发到我邮箱中!!谢谢!小弟只有30分了,全部拿出来!
jinlei198561@yahoo.com.cn 展开
2个回答
展开全部
Private Sub Form_Load()
Data1.DatabaseName = App.Path & "\mrlc.mdb" '打开数据库
Data2.DatabaseName = App.Path & "\mrlc.mdb" '打开数据库
End Sub
Private Sub Form_Activate() '系统初始化
Combo1.Text = "产品名称"
Combo2.Text = "like"
Combo3.Text = "产品名称"
Combo4.AddItem ("Asc")
Combo4.AddItem ("Desc")
Combo4.Text = "Asc"
End Sub
Private Sub Command1_Click()
If Check1.Value = 0 Then
If Check2.Value = 0 Then '查询所有数据
Data1.RecordSource = "select * from kc"
Data1.Refresh
End If
If Check2.Value = 1 Then '模糊查询
Data1.RecordSource = "select * from kc where ((kc." & Combo1.Text & " LIKE" + Chr(34) + Text1.Text + "*" + Chr(34) + "))"
Data1.Refresh
End If
End If
If Check1.Value = 1 Then
If Check2.Value = 0 Then '查询所有数据并排序
Data1.RecordSource = "select * from kc order by " & Combo3.Text & " " & Combo4.Text
Data1.Refresh
End If
If Check2.Value = 1 Then '模糊查询并排序
Data1.RecordSource = "select * from kc where ((kc." & Combo1.Text & " LIKE" + Chr(34) + Text1.Text + "*" + Chr(34) + "))order by " & Combo3.Text & " " & Combo4.Text
Data1.Refresh
End If
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Data1.DatabaseName = App.Path & "\mrlc.mdb" '打开数据库
Data2.DatabaseName = App.Path & "\mrlc.mdb" '打开数据库
End Sub
Private Sub Form_Activate() '系统初始化
Combo1.Text = "产品名称"
Combo2.Text = "like"
Combo3.Text = "产品名称"
Combo4.AddItem ("Asc")
Combo4.AddItem ("Desc")
Combo4.Text = "Asc"
End Sub
Private Sub Command1_Click()
If Check1.Value = 0 Then
If Check2.Value = 0 Then '查询所有数据
Data1.RecordSource = "select * from kc"
Data1.Refresh
End If
If Check2.Value = 1 Then '模糊查询
Data1.RecordSource = "select * from kc where ((kc." & Combo1.Text & " LIKE" + Chr(34) + Text1.Text + "*" + Chr(34) + "))"
Data1.Refresh
End If
End If
If Check1.Value = 1 Then
If Check2.Value = 0 Then '查询所有数据并排序
Data1.RecordSource = "select * from kc order by " & Combo3.Text & " " & Combo4.Text
Data1.Refresh
End If
If Check2.Value = 1 Then '模糊查询并排序
Data1.RecordSource = "select * from kc where ((kc." & Combo1.Text & " LIKE" + Chr(34) + Text1.Text + "*" + Chr(34) + "))order by " & Combo3.Text & " " & Combo4.Text
Data1.Refresh
End If
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询