如何在sql中使用参数,来传递textbox的值?能举个例子么?谢谢~~~

解决方案 »

  1.   

    sql="select * from table where username='" + 变量 + "'"
      

  2.   

    我是这样写的,怎么没用啊,是新手,望见亮啊~~:)
    Dim n As Char
            Dim conn As OleDbConnection
            Dim comm3 As OleDbCommand
            Dim dr3 As OleDbDataReader
            n = tb1.Text
            Dim selstr3 As String = "select subject,body from content  where sender='" + n + "'"
            conn = New OleDbConnection("provider=microsoft.jet.oledb.4.0; data source=" & Server.MapPath("discuss.mdb"))        Try
               comm3 = New OleDbCommand(selstr3, conn)
                conn.Open()
                dr3 = comm3.ExecuteReader
                dg3.DataSource = dr3
                dg3.DataBind()
                 conn.Close()          Finally
            End Try