VB.NET Insert text from SQL CELL into textbox.

I have a program i am writing for archiving,
During the search when it pulls the database showing the

Name    Provider   Location
file1       ATT          c:\scan.att.pdf

I want my AxAcroPDF1_ to load it. when the user clicks it. Unforutunately, the following peice of code does nto work.

the code i tried is

AxAcroPDF1.src = LOCATIONTextBox.Text i belive the issue is that its not pulling the new text that is done from the event textchange.  

So i need a code that will take the code text that is put into the LOCATIONTTEXTbox and use it as the source for the adobe reader. Please help. its for work. its a really cool program too if anyone care to have a copy when im done. It scans and archives.
desiredforsomeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Meir RivkinFull stack Software EngineerCommented:
can u post the code you used so i can test it on my machine?
Bob LearnedCommented:
I believe that a better approach is to use System.Diagnostics.Process.Start(fileName), which uses the file association to open the .pdf file in Acrobat Reader.
desiredforsomeAuthor Commented:
i got the code that works i pasted it below but im having troubel with it. if i click something blank the program crashes. i want an if statemtn that says like

if searchdocumentdatagridview.result<>o then
 Dim i As Integer
            i = SearchdocumentDataGridView.CurrentRow.Index
            AxAcroPDF1.src = SearchdocumentDataGridView.Item(2, i).Value
            AxAcroPDF1.Show()
            AxAcroPDF1.setView("FitB")
            AxAcroPDF1.setShowToolbar(False)
            AxAcroPDF1.setPageMode("none"

it works well right now however when i click a blank cell or search a record that doesnt exist it crashes. also anyone kno whow to get the blank row at the bottom of the datagrid from the stored procedure to go away? I dont want the blank row there.

Thank You I have just raised available points as well.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        InsertdocumentDataGridView.Hide()
        ProviderToolStripTextBox1.Text = ComboBox1.Text
        NameToolStripTextBox1.Text = TextBox1.Text
        Try
            Me.SearchdocumentTableAdapter.Fill(Me.ScanArchDataSet.searchdocument, NameToolStripTextBox1.Text, ProviderToolStripTextBox1.Text)
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try
        SearchdocumentDataGridView.Show()
        If SearchdocumentDataGridView.Rows.Contains(Of String)() Then
            Dim i As Integer
            i = SearchdocumentDataGridView.CurrentRow.Index
            AxAcroPDF1.src = SearchdocumentDataGridView.Item(2, i).Value
            AxAcroPDF1.Show()
            AxAcroPDF1.setView("FitB")
            AxAcroPDF1.setShowToolbar(False)
            AxAcroPDF1.setPageMode("none")
        End If
    End Sub

Open in new window

desiredforsomeAuthor Commented:
I think i got it this seems to work.

What do you think?
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        InsertdocumentDataGridView.Hide()
        ProviderToolStripTextBox1.Text = ComboBox1.Text
        NameToolStripTextBox1.Text = TextBox1.Text
        Try
            Me.SearchdocumentTableAdapter.Fill(Me.ScanArchDataSet.searchdocument, NameToolStripTextBox1.Text, ProviderToolStripTextBox1.Text)
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try
        SearchdocumentDataGridView.Show()
        Dim hasData As Boolean = False
        For i As Int32 = 0 To SearchdocumentDataGridView.RowCount - 2

            For j As Int32 = 0 To SearchdocumentDataGridView.RowCount - 1

                If SearchdocumentDataGridView(i, j).ToString <> Nothing Then
                    hasData = True
                    Exit For
                End If
            Next
        Next
        If hasData = True Then
            Dim i As Integer
            i = SearchdocumentDataGridView.CurrentRow.Index
            AxAcroPDF1.src = SearchdocumentDataGridView.Item(2, i).Value
            AxAcroPDF1.Show()
            AxAcroPDF1.setView("FitB")
            AxAcroPDF1.setShowToolbar(False)
            AxAcroPDF1.setPageMode("none")
        Else
            MsgBox(Title:="NO RECORDS FOUND", Prompt:="There are no records matching your query")
        End If
    End Sub
End Class

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.