Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2013-01-11
2
Medium Priority
?
1,083 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:Eric Burton
[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 1000 total points
ID: 38769815
Put following at the beginning

DataGridView1.EndEdit()
0
 
LVL 9

Accepted Solution

by:
sognoct earned 1000 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

610 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