簡體   English   中英

搜索帶有采購訂單編號的數據並將其顯示在datagridview中

[英]Searching for a data with purchase order number and displaying them in datagridview

昏暗的conn作為新的System.Data.OleDb.OleDbConnection()conn.ConnectionString =“ -----”

    Dim SqlString1 As String = "select * from tbl_po where prno='" & textboxall.Text & "' and rev='" & TextBoxrev.Text & "'"

    If ComboBox1.Text = "PR No. & Rev." Then
        Dim dt As New DataTable
        Dim da As New OleDbDataAdapter(SqlString1, conn)
        conn.Open()
        da.Fill(dt)
        DataGridView2.DataSource = dt
        conn.Close()
        If (DataGridView2.Rows.Count > 1) Then
            MessageBox.Show("Record Found")
        Else
            MessageBox.Show("No Record Found")
        End If
    End If

該程序沒有在gridview中顯示任何內容,只有colums標頭可以幫助我嗎?

試試看..

Dim SqlString1 As OleDbCommand = New OleDbCommand("select * from tbl_po where prno='" & textboxall.Text & "' and rev='" & TextBoxrev.Text & "'", conn)

If ComboBox1.Text = "PR No. & Rev." Then
    Dim da As New OleDbDataAdapter(SqlString1)
    Dim ds As DataSet = New DataSet()
    conn.Open()
    da.Fill(ds, "Table")
    DataGridView2.DataSource = ds
    DataGridView2.DataMember = "Table"
    conn.Close()
    If (DataGridView2.Rows.Count > 1) Then
        MessageBox.Show("Record Found")
    Else
        MessageBox.Show("No Record Found")
    End If
End If

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM