查询语句出错,如何解决?急,等!!@!!
我想把从数据库里查到的结果付给TXTBOX,可老提示
其他信息:语法错误 (操作符丢失) 在查询表达式 'count(DISTINCT Xqmc)' 中。
代码:
Private Sub ButCx_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButCx.Click
Dim Sql As String, RsFltj As New ADODB.Recordset()
Dim DcndCount As String
Sql = "SELECT count(DISTINCT Xqmc) as var FROM Nhsfdcb1 where Dcnd='" & ComBoxDcnd.SelectedItem.ToString & "'"
RsFltj.Open(Sql, gDBDat, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockReadOnly)
If RsFltj.RecordCount > 0 Then
RsFltj.MoveFirst()
DcndCount = RsFltj.RecordCount.ToString
TxtXq.Text = DcndCount.ToString
RsFltj.Close() : RsFltj = Nothing
End If
End Sub