Solved

Urgent! VB.NET -- Need to execute a TableAdapter query using a DataGridView column value!

Posted on 2013-01-11
2
1,000 Views
Last Modified: 2013-01-12
Hi everyone,

I have a TableAdapter which is filled with multiple queries.

I want to use a DataGridViewCell value as a parameter in a TableAdapter query

My current code throws an exception because the DataGridViewCell value is returning as dbNull even though it has a value.

Here is the current code which is taken from a Form KeyUp event:

Select Case e.KeyCode
            Case Keys.F8
                Dim columnValue As String = DataGridView1.Currentcell.Value.ToString()

                        Try
                            ' Me.Table1TableAdapter.FillByQuery1(Me.Dataset1.Table1, columnvalue)
                        Catch ex As Exception
                            MessageBox.Show(ex.Message)
                        End Try


        End Select

Thanks for your help!
0
Comment
Question by:eq2006
2 Comments
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 250 total points
Comment Utility
Put following at the beginning

DataGridView1.EndEdit()
0
 
LVL 9

Accepted Solution

by:
sognoct earned 250 total points
Comment Utility
Case Keys.F8
                DataGridView1.EndEdit()
                Me.Dataset1.Table1.acceptchanges()

                Dim columnValue As String = DataGridView1.Currentcell.Value.ToString()

                        Try
                            ' Me.Table1TableAdapter.FillByQuery1(Me.Dataset1.Table1, columnvalue)
                        Catch ex As Exception
                            MessageBox.Show(ex.Message)
                        End Try


        End Select
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now