none
如何在textbox中显示SQL数据查询值 RRS feed

  • 问题

  •     Dim connstr As New String("provider=sqloledb.1;user id = sa ;password=123;persist security info=false;initial catalog=ttt;data source=aaa")
        Dim cn As New OleDbConnection
        Dim searchsql As String
        Dim cmd1 As New OleDbDataAdapter
        Dim returnValue As New DataSet

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            searchsql = "SELECT b,c,e,f,g,h,i from Table_1 where a = '" & Me.TextBox1.Text & "' "
            Try
                cn.ConnectionString = connstr
                cn.Open()
                cmd1 = New OleDbDataAdapter(searchsql, cn)
                cmd1.Fill(returnValue, "table_1")
                Me.TextBox2.Text = returnValue.Tables.Item(1).ToString
                cn.Dispose()
            Catch ex As Exception
                MsgBox(ex.Message)
                cn.Dispose()
            End Try
        End Sub 请问这样写对吗?为什么老是提示‘找不到表1’,正确的应该怎么写?

    2013年11月4日 3:02

答案

全部回复