Solved

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

Posted on 2013-01-11
2
1,042 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

730 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