Solved

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

Posted on 2013-01-11
2
1,027 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
ID: 38769815
Put following at the beginning

DataGridView1.EndEdit()
0
 
LVL 9

Accepted Solution

by:
sognoct earned 250 total points
ID: 38769864
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Visual Studios 1 76
How to limit User Input 2 27
Returning a value from a class function to a partial view in MVC5 7 28
jquery tab header text 1 23
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

856 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