主题:求助 VB 连接数据库语句错误
大家看看这是怎么回事,代码如下:
Public Sub RefreshScoreData(StuID As String)
Dim strSql As String
Dim Rs As New ADODB.Recordset
If Option1.Value Then
strSql = "and students.StuID= '" & StuID & " 'order by SYear DESC"
Else
strSql = "and Score.SYear1= '" & CboYear1.Text & " 'and Score.SYear2='" & CboYear2.Text & "'and Score.STerm='" & CboTerm.Text & "'" & m_QuerySql
If CboASC.ListIndex = 0 Then
strSql = strSql & "order by StuNo "
ElseIf CboASC.ListIndex = 1 Then
strSql = strSql & "order by SOrder "
End If
End If
strSql = "select Score.*,(SYear1 +'~ '+ SYear2 + '('+STerm+')') as SYear," & _
"students.StuNo,StuName from Score,students" & _
"where Score.StuID=students.StuID" & strSql
Rs.Open strSql, Conn, adOpenStatic, adLockReadOnly
Set dg_Score.DataSource = Rs
End Sub
运行老是提示 第一行:'.' 附近有语法错误 找了半天也没有发现错误在哪里?大虾指教啊
Public Sub RefreshScoreData(StuID As String)
Dim strSql As String
Dim Rs As New ADODB.Recordset
If Option1.Value Then
strSql = "and students.StuID= '" & StuID & " 'order by SYear DESC"
Else
strSql = "and Score.SYear1= '" & CboYear1.Text & " 'and Score.SYear2='" & CboYear2.Text & "'and Score.STerm='" & CboTerm.Text & "'" & m_QuerySql
If CboASC.ListIndex = 0 Then
strSql = strSql & "order by StuNo "
ElseIf CboASC.ListIndex = 1 Then
strSql = strSql & "order by SOrder "
End If
End If
strSql = "select Score.*,(SYear1 +'~ '+ SYear2 + '('+STerm+')') as SYear," & _
"students.StuNo,StuName from Score,students" & _
"where Score.StuID=students.StuID" & strSql
Rs.Open strSql, Conn, adOpenStatic, adLockReadOnly
Set dg_Score.DataSource = Rs
End Sub
运行老是提示 第一行:'.' 附近有语法错误 找了半天也没有发现错误在哪里?大虾指教啊