我在查询芯片数据库的内容时显示的是我全部的数据库内容,而不是我想要得数据,而且只能点击一次查询按键,再点程序就进入我自己写的错误提示里面了。希望大家能帮我解决,我是个新手第一次用VB写软件。下面是我查询界面的全部代码,想要我全部程序可以加我的QQ14215947或是留下邮箱我给发过去。(附件传不上来,请见谅)
Option Explicit
Dim rs_find As New ADODB.RecordsetPrivate Sub Command1_Click()
On Error GoTo cmderror
Dim find_date1 As String
Dim find_date2 As String
If Option1.Value = True Then
sqlfind = "select * from 芯片库 where 品名 = '" & Combo1.Text & "'"
End If
If Option2.Value = True Then
find_date1 = Format(CDate(comboy(0).Text & "-" & _
combom(0).Text & "-" & combod(0).Text), "yyyy-mm-dd")
find_date2 = Format(CDate(comboy(1).Text & "-" & _
combom(1).Text & "-" & combod(1).Text), "yyyy-mm-dd")
sqlfind = "select * from 芯片库 where 进货日期 between #" & _
find_date1 & "#" & " and" & " #" & find_date2 & "#"
End If
rs_data1.Open sqlfind, conn, adOpenKeyset, adLockPessimistic
Adodc1.Refresh
cmderror:
If Err.Number <> 0 Then
MsgBox "请输入正确的查询条件!", vbOKOnly + vbExclamation, "警告"
End If
End SubPrivate Sub Command2_Click()
Unload Me
End SubPrivate Sub Form_Load()
Dim i As Integer
Dim j As Integer
Dim sql As String
'If findok = True Then
'rs_data1.Close
'End If
sql = "select * from 芯片库 order by 品名 desc"
rs_find.CursorLocation = adUseClient
rs_find.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_find.EOF = False Then '添加品名
With rs_find
Do While Not .EOF
Combo1.AddItem .Fields(1)
.MoveNext
Loop
End With
End If
For i = 2001 To 2010 '添加年
comboy(0).AddItem i
comboy(1).AddItem i
Next i
For i = 1 To 12 '添加月
combom(0).AddItem i
combom(1).AddItem i
Next i
For i = 1 To 31 '添加日
combod(0).AddItem i
combod(1).AddItem i
Next iEnd SubPrivate Sub Option1_Click()
Option2.Value = False
End SubPrivate Sub Option2_Click()
Option1.Value = False
End SubPrivate Sub Form_Unload(Cancel As Integer)
rs_find.Close
End Sub
Option Explicit
Dim rs_find As New ADODB.RecordsetPrivate Sub Command1_Click()
On Error GoTo cmderror
Dim find_date1 As String
Dim find_date2 As String
If Option1.Value = True Then
sqlfind = "select * from 芯片库 where 品名 = '" & Combo1.Text & "'"
End If
If Option2.Value = True Then
find_date1 = Format(CDate(comboy(0).Text & "-" & _
combom(0).Text & "-" & combod(0).Text), "yyyy-mm-dd")
find_date2 = Format(CDate(comboy(1).Text & "-" & _
combom(1).Text & "-" & combod(1).Text), "yyyy-mm-dd")
sqlfind = "select * from 芯片库 where 进货日期 between #" & _
find_date1 & "#" & " and" & " #" & find_date2 & "#"
End If
rs_data1.Open sqlfind, conn, adOpenKeyset, adLockPessimistic
Adodc1.Refresh
cmderror:
If Err.Number <> 0 Then
MsgBox "请输入正确的查询条件!", vbOKOnly + vbExclamation, "警告"
End If
End SubPrivate Sub Command2_Click()
Unload Me
End SubPrivate Sub Form_Load()
Dim i As Integer
Dim j As Integer
Dim sql As String
'If findok = True Then
'rs_data1.Close
'End If
sql = "select * from 芯片库 order by 品名 desc"
rs_find.CursorLocation = adUseClient
rs_find.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_find.EOF = False Then '添加品名
With rs_find
Do While Not .EOF
Combo1.AddItem .Fields(1)
.MoveNext
Loop
End With
End If
For i = 2001 To 2010 '添加年
comboy(0).AddItem i
comboy(1).AddItem i
Next i
For i = 1 To 12 '添加月
combom(0).AddItem i
combom(1).AddItem i
Next i
For i = 1 To 31 '添加日
combod(0).AddItem i
combod(1).AddItem i
Next iEnd SubPrivate Sub Option1_Click()
Option2.Value = False
End SubPrivate Sub Option2_Click()
Option1.Value = False
End SubPrivate Sub Form_Unload(Cancel As Integer)
rs_find.Close
End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货