Private Sub Command筛选_Click()
Public b As String
Public c As String
Dim str As String
str = "select * from 学生 where 1=1"
If Combo1.Text <> "全部" Then
str = str + "and 班级='" & Combo1.Text & "' "
End If
If Combo2.Text <> "全部" Then
str = str + "and 性别='" & Combo2.Text & "'"
End If
If Combolc.Text = "全部学生" Then
b = 0
c = 100
End If
If Combolc.Text = "不极格" Then
b = 0
c = 60
End If
If Combolc.Text = "良" Then
b = 61
c = 70
End If
If Combolc.Text = "优" Then
b = 71
c = 100
End If
If Combolc.Text <> "全体同学" Then
str = str + "and 成绩 > " + b + " and 成绩 < " + c (主要是这里的问题引号怎么个加法)
End If
Adodc1.RecordSource = str
Adodc1.Refresh
End Sub
Public b As String
Public c As String
Dim str As String
str = "select * from 学生 where 1=1"
If Combo1.Text <> "全部" Then
str = str + "and 班级='" & Combo1.Text & "' "
End If
If Combo2.Text <> "全部" Then
str = str + "and 性别='" & Combo2.Text & "'"
End If
If Combolc.Text = "全部学生" Then
b = 0
c = 100
End If
If Combolc.Text = "不极格" Then
b = 0
c = 60
End If
If Combolc.Text = "良" Then
b = 61
c = 70
End If
If Combolc.Text = "优" Then
b = 71
c = 100
End If
If Combolc.Text <> "全体同学" Then
str = str + "and 成绩 > " + b + " and 成绩 < " + c (主要是这里的问题引号怎么个加法)
End If
Adodc1.RecordSource = str
Adodc1.Refresh
End Sub
str = str + "and 成绩 > " + b + " and 成绩 < " + c (主要是这里的问题引号怎么个加法)
//str = "select * from 学生 where 1=1"
应该有空格
str = "select * from 学生 where 1=1 "
后面加空格
str = str + "and 性别='" & Combo2.Text & "' "或者
str = str & "and 成绩 > " & b & " and 成绩 < " & c
前面加空格
str = str & " and 成绩 > " & b & " and 成绩 < " & c
请问各位高手有什么资料是专门讲ADO+SQL数据筛选加引号的啊。
代码我试试啊
或是用 debug.print str 測一下也行啊!