0
Private Function Gelobee() As DataSet
    Dim connection As OleDb.OleDbConnection = New OleDbConnection
    connection.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=CMP.accdb"
    connection.Open()
    Dim da As OleDb.OleDbDataAdapter = New OleDbDataAdapter("SELECT IDDesc FROM [ItemDesc] WHERE " & PartNoTxt.Text & " ORDER BY IDID;", connection)
    Dim ds As New DataSet
    da.Fill(ds, "FilteredDesc")
    Return ds
    connection.Dispose()
    connection = Nothing
    DescTxt.Text = ds.Tables(0).Rows(1).Item(1)
End Function

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Gelobee()
End Sub

I am trying to get the result of the query in Function Gelobee to go to DescTxt.Text when I click the Button1. When I click the Button1, nothing appears in the DescTxt. No errors but It wont show the result in the textbox.

1 Answer 1

1

Your code stops at the Return statement.

Change Gelobee() to this:

Private Function Gelobee() As DataSet
    ... ' Removed for brevity

    da.Fill(ds, "FilteredDesc")
    connection.Dispose()
    connection = Nothing
    DescTxt.Text = ds.Tables(0).Rows(1).Item(1)
    Return ds
End Function
Sign up to request clarification or add additional context in comments.

1 Comment

I am glad to be able to help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.