原文:Dim DS As DataSet        Dim MyConnection As SqlConnection
        Dim mycommand As SqlDataAdapter
        MyConnection = New SqlConnection("server=127.0.0.1;database=text;uid=sa;pwd=;")
        MyConnection.Open()
        Dim str As String
        str = "select * from student where tth='" & TextBox4.Text & "' "        mycommand = New SqlDataAdapter(str, MyConnection)        DS = New DataSet        'Try
        mycommand.Fill(DS, "student")
        datagrid1.DataSource = DS.Tables("student").DefaultView
        datagrid1.DataBind()
        MyConnection.Close()
错误:第 1 行: ' ' 附近有语法错误。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 
异常详细信息: System.Data.SqlClient.SqlException: 第 1 行: ' ' 附近有语法错误。源错误: 
行 389:
行 390:
行 391:        mycommand.Fill(DS, "student")
行 392:        datagrid1.DataSource = DS.Tables("student").DefaultView
行 393:        datagrid1.DataBind()
 源文件: G:\毕业设计\WebApplication1\manager1.aspx.vb    行: 391 在此事件下面 还有一类似的与datagrud1的绑定查询  可以正常显示!!  tth 是int型 而且数据库中有几个student的tth就是1,但是即使我使用str = "select * from student where tth=1 "或者'1'
都是出现相同的错误
恳请各位高手指点

解决方案 »

  1.   

    str = "select * from student where tth=" & TextBox4.Text 
     这样试试....
     
      

  2.   

    不行啊   
        我使用str = "select * from student where tth=1 "或者'1' 的时候都一样报错
      

  3.   

    str = "select * from student where tth='" & TextBox4.Text & "'"student where之间你用了个全角的空格,这样试试看!
      

  4.   

    to  hackate(兰花开香入梦境,独思佳人亦飘然!!) ( )
        hackate(兰花开香入梦境,独思佳人亦飘然!!) ( )
      
      太谢谢你了 
       就是它的事了