0

根据下拉列表项,我在动态图表的页面加载时不断收到此错误:

* ')' 附近的语法不正确。异常详细信息:System.Data.SqlClient.SqlException:')' 附近的语法不正确。源错误:

第 44 行:objAdapter.Fill(objDataSet)*

页面加载代码:

    DropDownList1.Text = "Show All"
    Dim strSQLQuery As String
    Dim objConnection As SqlConnection
    Dim objCommand As SqlCommand
    Dim objAdapter As SqlDataAdapter
    Dim objDataSet As DataSet

    objConnection = New SqlConnection("Data Source=MYSVR01;Initial Catalog=HMBX;Integrated Security=True")

    If DropDownList1.Text = "Show All" Then
        strSQLQuery = "SELECT * from table"
    Else
        strSQLQuery = "SELECT * from table where col1 = '"& dropdownlist1.text &'""
    End If
    objCommand = New SqlCommand(strSQLQuery, objConnection)

    objAdapter = New SqlDataAdapter(objCommand)
    objDataSet = New DataSet()
    objAdapter.Fill(objDataSet)

    'Dim source As New DataView(objDataSet.Tables(0))

    Chart1.DataSource = objDataSet
    Chart1.Series("Series1").XValueMember = "TimeOfDay"
    Chart1.Series("Series1").YValueMembers = "visitors"

    Chart1.DataBind()

感谢您的意见...谢谢!

4

1 回答 1

0

问题已解决...必须更正 sql 中的一些语法错误

于 2013-01-08T09:14:08.993 回答