返回列表 发帖

紧急求助,热心的会VB的进!!!

[这个贴子最后由清风流水在 2005/08/23 08:37pm 第 1 次编辑] 最近用VB通宵做个图书管理系统,但是有错没法继续了 请大家帮帮忙,我的QQ327703857,要用到连接数据库的知识 谢谢了,感激不尽!!! Dim rs As ADODB.Recordset Public s1 As String Private Sub Cmdadd_Click(Index As Integer) Dim Sql As String Dim i As Integer Call showed Select Case Index Case 0 Call Cmbstyled For i = 1 To 5 Txtlib(i).Text = "" Next Txtlib(6).Text = "1" '; Txtlib(0).Text = "BK" & Right("000" & (s1 + 1), 3) Cmbstyle.Text = "---请输入类型---" Case 1 If Txtlib(1).Text = "" Then MsgBox "书名不能为空!!" Txtlib(1).SetFocus ElseIf Txtlib(2).Text = "" Then MsgBox "作者不能为空!!" Txtlib(2).SetFocus ElseIf Txtlib(3).Text = "" Then MsgBox "出版日期不能为空!!" Txtlib(3).SetFocus MsgBox Date & "以前" ElseIf Txtlib(4).Text = "" Then MsgBox "出版社不能为空!!" Txtlib(4).SetFocus ElseIf Cmbstyle.Text = "" Or Cmbstyle.Text = "---请输入类型---" Then MsgBox "图书类型不能为空!!" Cmbstyle.SetFocus ElseIf Txtlib(5).Text = "" Then MsgBox "关键字不能为空!!" Txtlib(5).SetFocus ElseIf Txtlib(6).Text = "" Then MsgBox "数量不能为空!!" Txtlib(6).SetFocus ElseIf Txtlib(3).Text <= Date Then Sql = "insert into library values(';" & Txtlib(0).Text & _ "';,';" & Txtlib(1).Text & "';,';" & Txtlib(2).Text & "';,';" & _ Txtlib(3).Text & "';,';" & Txtlib(4).Text & "';,';" & Cmbstyle.Text & _ "';,';" & Txtlib(5).Text & "';," & Val(Txtlib(6).Text) & ")" Call Con_Exectue(Sql) MsgBox "成功入库!!" Else MsgBox "日期错误!!" Txtlib(3).SetFocus MsgBox Date & "以前" End If Case 2 Set jk = Nothing Unload Me MDIFrmmain.Show ';Case 3 End Select End Sub Private Sub Cmdmove_Click(Index As Integer) Select Case Index Case 0 rs.MoveFirst Case 1: rs.MovePrevious If rs.BOF Then rs.MoveFirst Case 2: rs.MoveNext If rs.EOF Then rs.MoveLast Case 3: rs.MoveLast End Select Call TxtData End Sub Private Sub Form_Load() Set rs = GetRs("library") Call TxtData ';Call showed ';Cmbstyle.AddItem "小说" ';Cmbstyle.AddItem "外国文学" ';Cmbstyle.AddItem "扯蛋" ';Cmbstyle.AddItem "列传" ';Cmbstyle.AddItem "幼稚园读物" ';Cmbstyle.AddItem "学习用书" End Sub Sub showed() Call library jk.Open "library" jk.MoveLast s1 = jk.Fields(0).Value jk.Close Set jk = Nothing Txtlib(0).Text = "BK" & Right("000" & (s1 + 1), 3) End Sub Sub TxtData() ';向文本框添加信息 Txtlib(0).Text = "BK" & Right("000" & rs.Fields(0).Value, 3) Txtlib(1).Text = rs.Fields(1).Value Txtlib(2).Text = rs.Fields(2).Value Txtlib(3).Text = rs.Fields(3).Value Txtlib(4).Text = rs.Fields(4).Value Cmbstyle.Text = rs.Fields(5).Value Txtlib(5).Text = rs.Fields(6).Value Txtlib(6).Text = rs.Fields(7).Value End Sub Sub Cmbstyled() Cmbstyle.AddItem "小说" Cmbstyle.AddItem "外国文学" Cmbstyle.AddItem "扯蛋" Cmbstyle.AddItem "列传" Cmbstyle.AddItem "幼稚园读物" Cmbstyle.AddItem "学习用书" End Sub 下面是模块 Public jk As ADODB.Recordset ';Dim cn As New ADODB.Connection ';Dim rs As New ADODB.Recordset ';cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbadd Sub library() Set jk = New ADODB.Recordset jk.ActiveConnection = "file name=library.udl" jk.CursorLocation = adUseClient jk.CursorType = adOpenDynamic jk.LockType = adLockOptimistic End Sub Public Sub Con_Exectue(Str As String) Dim cn As ADODB.Connection Set cn = New ADODB.Connection cn.ConnectionString = "file name=library.udl" '; Cn.Open '; Cn.Execute Str '; Cn.Close Set cn = Nothing End Sub Public Function GetRs(Str As String) As ADODB.Recordset Dim rs As ADODB.Recordset Set rs = New ADODB.Recordset rs.CursorLocation = adUseClient '; Rs.ActiveConnection = "file name=library.udl" '; Rs.CursorType = adOpenStatic '; Rs.LockType = adLockOptimistic rs.Open Str, "file name=library.udl", adOpenStatic, adLockOptimistic '; Rs.Source = "library" Set GetRs = rs End Function Public Sub dblink() Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset cn.Open "Provider=library.udl" & dbadd End Sub

紧急求助,热心的会VB的进!!!

这个估计不太好帮 你还是咨询下你们的开发小组组长 或是你们的培训老师吧
我一朋友当初遇到这个问题的时候也是自己钻研+老师问 解决的

TOP

紧急求助,热心的会VB的进!!!

我时间紧啊,才3天就要完成了

TOP

紧急求助,热心的会VB的进!!!

恩 不好意思 我是不懂这个东西
恩,我建议你最好还是问下你们一起学习的学员或是同学什么的或是直接问老师
一般都会获得解答。
如果你们是小组开发 你就问你们小组组长

TOP

紧急求助,热心的会VB的进!!!

晕。。。。自学怎么办啊,不靠论坛的朋友我靠谁啊

TOP

紧急求助,热心的会VB的进!!!

调试之后有什么错误提示?

TOP

紧急求助,热心的会VB的进!!!

顶上来!!!!!!!!!!!!!!!!

TOP

紧急求助,热心的会VB的进!!!

噢 是自学编写的啊  恩 呵呵 那我帮你转到编程班 让人给你看看

TOP

紧急求助,热心的会VB的进!!!

[这个贴子最后由ouli在 2005/08/24 07:54am 第 1 次编辑]

连接数据库?~ACCESS吧?~???
是连接ACCESS有错,
我帮你找找看,

TOP

紧急求助,热心的会VB的进!!!

好,谢谢楼上的,加油啊
其他大虾也来讨论!!!

TOP

返回列表 回复 发帖