?
Solved

Query as Datasource for Datagridview: Query not Listed as an Option

Posted on 2008-06-23
3
Medium Priority
?
399 Views
Last Modified: 2013-11-26
In Visual Basic 2008, I have a simple form with a Datagridview control.  I have a project dataset in which I have attached perhaps 20 tables from my SqlServer Database.  I have made a query that joins 2 tables and there is a query table adapter shown in the dataset explorer, and the query table adapter shows my query, named Lookupvisits().  On the Datagridview, when I click on "choose data source" and I expand the tree structure of my project datasources, the query is not shown.  What am I doing wrong? of note, when I click on the query properties, the execute mode property shows 'scalar'- "reader" is not an option, if that matters.  Thank you.
0
Comment
Question by:SqlServerDoc
  • 2
3 Comments
 
LVL 41

Accepted Solution

by:
graye earned 500 total points
ID: 21846030
When you built the query in the DataSet designer, did you use the "Query" object or the "TableAdapter" object?

It may seem a bit counter-intuitive, but if your query returns a table, you should use a TableAdapter rather than a Query
0
 

Author Closing Comment

by:SqlServerDoc
ID: 31469714
Excellent.  I wish there was better documentation (msdn etc) available! thank you!
0
 

Author Comment

by:SqlServerDoc
ID: 21846201
For other beginners, when defining a query datasource in the designer, click on Add > Table Adapter rather than query.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month13 days, 8 hours left to enroll

749 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