这是我查询页面的代码
Private sType As IntegerPrivate Sub Command1_Click()
Build_Search_SQL
Unload Me
frmchaxunxianshiQiyeJiben.Show
End SubPrivate Sub Command2_Click()
Unload Me
End SubPrivate Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)End SubSub Build_Search_SQL()
Dim s2 As String, s3 As String '修改
s3 = "select 企业名称,上年度销售收入(亿元),资产总额(亿元),年屠宰加工能力(万只/头),肉制品加工能力(万吨),冷藏能力(万吨),在岗职工(万人),主导产品,产品销售地,机械化程度,商标名称,商标级别,名牌产品名称,名牌产品级别,认证,出口企业,集团下属企业,分布地,所属省份," '修改
s2 = Join_Condition
Select Case sType
Case 0
frmchaxunxianshiQiyeJiben.sqlstr = s3 & " from 企业基本情况表" '修改
Case 1
If s2 <> "" Then
s2 = " where " & s2
frmchaxunxianshiQiyeJiben.sqlstr = s3 & " from 企业基本情况表 " & s2 '修改
End If
End Select
End Sub
Function Join_Condition() As String
Dim s1 As String
If Check1.Value = 1 And Text1.Text <> "" Then
s1 = " 企业基本情况表.企业名称 like '%" & Text1.Text & "%'"
End If
If Check2.Value = 1 And Text2.Text <> "" Then
s1 = s1 & " and 企业基本情况表.上年度销售收入(亿元) like '%" & Text2.Text & "%'"
End If
If Left(s1, 2) = " and" Then
s1 = Right(s1, Len(s1) - 2)
End If
Join_Condition = s1
End FunctionPrivate Sub Option1_Click()
sType = 0
End SubPrivate Sub Option2_Click()
sType = 1
End Sub
这是我查询显示页面的代码Public sqlstr As StringPrivate Sub Form_Load()
MSHFlexGrid1.Clear
Adodc1.Recordset.Close
Adodc1.Recordset.Open sqlstr
SetWidth
End Sub
Sub SetWidth()
Dim i As Integer
Dim s As String
For i = 0 To Adodc1.Recordset.Fields.Count - 1
MSHFlexGrid1.ColWidth(i) = 1000
Next
End SubPrivate Sub Form_Resize()
MSHFlexGrid1.Width = frmchaxunxianshiQiyeJiben.Width - 20
MSHFlexGrid1.Height = frmchaxunxianshiQiyeJiben.Height - 20
End Sub运行时出现以下错误提示:实时性错误 FROM 子句语法错误。调试后错误定位在查询显示页面的 Adodc1.Recordset.Open sqlstr 地方。
请各位高手给小弟解答一下,真是麻烦了
Private sType As IntegerPrivate Sub Command1_Click()
Build_Search_SQL
Unload Me
frmchaxunxianshiQiyeJiben.Show
End SubPrivate Sub Command2_Click()
Unload Me
End SubPrivate Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)End SubSub Build_Search_SQL()
Dim s2 As String, s3 As String '修改
s3 = "select 企业名称,上年度销售收入(亿元),资产总额(亿元),年屠宰加工能力(万只/头),肉制品加工能力(万吨),冷藏能力(万吨),在岗职工(万人),主导产品,产品销售地,机械化程度,商标名称,商标级别,名牌产品名称,名牌产品级别,认证,出口企业,集团下属企业,分布地,所属省份," '修改
s2 = Join_Condition
Select Case sType
Case 0
frmchaxunxianshiQiyeJiben.sqlstr = s3 & " from 企业基本情况表" '修改
Case 1
If s2 <> "" Then
s2 = " where " & s2
frmchaxunxianshiQiyeJiben.sqlstr = s3 & " from 企业基本情况表 " & s2 '修改
End If
End Select
End Sub
Function Join_Condition() As String
Dim s1 As String
If Check1.Value = 1 And Text1.Text <> "" Then
s1 = " 企业基本情况表.企业名称 like '%" & Text1.Text & "%'"
End If
If Check2.Value = 1 And Text2.Text <> "" Then
s1 = s1 & " and 企业基本情况表.上年度销售收入(亿元) like '%" & Text2.Text & "%'"
End If
If Left(s1, 2) = " and" Then
s1 = Right(s1, Len(s1) - 2)
End If
Join_Condition = s1
End FunctionPrivate Sub Option1_Click()
sType = 0
End SubPrivate Sub Option2_Click()
sType = 1
End Sub
这是我查询显示页面的代码Public sqlstr As StringPrivate Sub Form_Load()
MSHFlexGrid1.Clear
Adodc1.Recordset.Close
Adodc1.Recordset.Open sqlstr
SetWidth
End Sub
Sub SetWidth()
Dim i As Integer
Dim s As String
For i = 0 To Adodc1.Recordset.Fields.Count - 1
MSHFlexGrid1.ColWidth(i) = 1000
Next
End SubPrivate Sub Form_Resize()
MSHFlexGrid1.Width = frmchaxunxianshiQiyeJiben.Width - 20
MSHFlexGrid1.Height = frmchaxunxianshiQiyeJiben.Height - 20
End Sub运行时出现以下错误提示:实时性错误 FROM 子句语法错误。调试后错误定位在查询显示页面的 Adodc1.Recordset.Open sqlstr 地方。
请各位高手给小弟解答一下,真是麻烦了
sqlstr="select * from 企业基本情况表"
MSHFlexGrid1.Clear
Adodc1.Recordset.Close
Adodc1.Recordset.Open sqlstr
SetWidth
End Sub