.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Using a Query as a data source for a grid

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :JQuery
Pardon the elementary nature of this question.  I have a SQL 2005 database with several queries.  I want to use the queries as data sources for grids in VS2008.  I connect the SQL database but cannot see the queries as a data source.  I have tried building the queries in code within VS but I still cannot use the query results as a grid data source.  Any Help would be greatly appreciated.

View Complete Post

More Related Resource Links

Cannon add new Data Source in Grid in VS2005 using SQL Server2005

I am a student and started out with VS2010 on my laptop.  Due to compatibility issues, I had to start using the provided version, 2005.  I uninstalled 2010 and now have the trial version of VS 2005 as well as SQL Server 2005. I have a data grid on a windows form and am attempting to use a database provided for the class.  When I use the smart tag to start the Wizard, as directed I do the following Select Add Project Data Source Choose Type..Database..Next In Choose Data Source Window, I select New Connection  Data source: MS SQL Server Database File..Continue In Add Connection Window, Data source: SQL Server Database File (SqlClient) Database file name...browse to database file in Student cd (E:\StudentData\DatabaseFilesSQLServerVersion\RnrBooks.mdf) Log on to the server: Use Windows Authentication And then press Test Connection Here is the error that I get: Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance.  The connection will be closed  

Using CROSS APPLY in a data source query causes ARITHABORT error


I have an issue where the following query as an OLEDB data source throws the following error:

SELECT XmlNode.value('SomeValue[1]', 'varchar(10)') as SomeValue

FROM (SELECT CAST('<TestXML><SomeValue>123</SomeValue></TestXML>' AS XML

How To Map A GUID Variable And Use It In An OLE DB Source Data Flow Select Query


I have a simple SSIS package that does the following. 

On the control flow tab, there is an Execute SQL task that calls a stored procedure and returns a GUID. 

I have a package scoped variable that stores a UNIQUEIDENTIFIER output from the stored procedure. It appears that the package variable data type does not include a GUID data type so I tried to use string instead.

Next, the Execute SQL task is mapped to a data flow task. 
Within that data flow task I have an OLE DB Source which connects to a SQL Server Destination task.

On the OLE DB Source Editor screen I have a query that performs the following:

SELECT ID, SessionKey, ....
FROM dba_DroppedLoginsLog
WHERE SessionKey = ?

I have clicked on the parameters button to map the Parameter to my variable called User::SessionKey. This is the output variable from my Execute SQL Task component on the Control Flow tab. This value should be a GUID, but again, I don't see a data type for that.

When I execute the package it fails on the OLE DB Source with the following error:
[OLE DB Source [1908]] Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE D

OLE DB Data Source Preview Shows Records in the Data Source but Grid Data Viewer Shows No Data Comin



I am running into a strange behavior when I try to test a simple package that contains a Data Flow Task with an OLE DB Source and OLE DB Destination. I can preview the records in the Data Source but when I run the package in the designer the Data Viewer I attached shows no data coming out of the data source. I am not using a package config file therefore nothing changes at runtime. I am using two package connection managers to connect to the source and destination. The package does complete successfully but data is never copied:

SSIS package "TestPackage.dtsx" starting.
Information: 0x4004300A at Data Flow Task, DTS.Pipeline: Validation phase is beginning.
Information: 0x40043006 at Data Flow Task, DTS.Pipeline: Prepare for Execute phase is beginning.
Information: 0x40043007 at Data Flow Task, DTS.Pipeline: Pre-Execute phase is beginning.
Information: 0x4004300C at Data Flow Task, DTS.Pipeline: Execute phase is beginning.
Information: 0x402090DF at Data Flow Task, OLE DB Destination [118]: The final commit for the data insertion has started.
Information: 0x402090E0 at Data Flow Task, OLE DB Destination [118]: The final commit for the data insertion has ended.
Information: 0x40043008 at Data Flow T

error when testing query during configuring sql data source for gridview


I got the following error message:

There was an error executing the query. Please check the syntax of hte the command and if present, the types and values of the parameters and ensure they are correct.  Failed to enable constraints.  One or more rows contain values violating non-null, unique, or foreign-key constraints.

But when I run the query through Management Studio, I can get the result. 

There are no parameters for this query either. 

Can anybody give me a glue what to check?


Passing report parameters to a query using a WCF data source


Hello everyone,


I am attempting to pass report parameters to my query. My report's data source is a WCF web service. I can run normal queries fine, but I have found that without the know-how to pass parameters to my query I am limited with my capabilities.

Assume a string parameter named "Name" with a specified default value of "Jmachol90", how would I pass that into the following query at the designated place:




          <Method Namespace="http://schemas.microsoft.com/sqlserver/masterdataservices/2009/09" Name="SecurityPrincipalsGetRequest">


          <Parameter Name="Criteria" Type="XML">









Data Mining Project in BIDS: Why cant data source views be based on a query?

I've created an analysis services project in BIDS with the intention of creating a mining strucuture. I notice that you cannot create a data source view based on a query and that it must be based on linking actual tables (via the access looking GUI).  In my scenario I have a very long and complicated query which uses temp tables to retreive the data I want to use for mining.   Am I forced to insert this data into a table in order to create and use a mining structure?  Or are there other ways to do it?

MS SQL Server: Search All Tables, Columns & Rows For Data or Keyword Query

If you need to search your entire database for specific data, this query will come in handy.

So when a client needs a custom report or some sort of custom development using Great Plains, most of the time I will have to track down the data in the system by running this query and find the table(s) it is in.

Toolbox: Data Snapshots, Subversion, Source Code Organization and More


If you want to save, organize, and annotate snapshots of your database data, find an easy way to install and configure Subversion, and automate the organization of your source code, then you'll want to read more about these latest tools.

Scott Mitchell

MSDN Magazine August 2009

Data Points: Standard Query Operators with LINQ


LINQ to Objects and LINQ to Entities have an arsenal of Standard Query Operators that operate on sequences to perform a wide variety of operations.

John Papa

MSDN Magazine March 2008

Toolbox: Updated grid controls, open-source comparison tools, and more


This time: Windows Forms grids, professional-looking date textboxes, file merging, and more.

Scott Mitchell

MSDN Magazine November 2007

Data Points: Data Source Controls in ASP.NET 2.0


ASP. NET 2. 0 introduces a series of new tools that improve data access including several data source and data bound controls. The new assortment of data source controls can eliminate a ton of repetitive code that was required in ASP.

John Papa

MSDN Magazine January 2005

Web Q&A: Storing SQL Data, URL Query Length, and More


Find out the best way to store large amounts of XML data in SQL Server, along with the performance implications. What's the maximum length of an XML query to SQL Server in a URL?

Edited by Nancy Michell

MSDN Magazine May 2003

Building a Custom Data Grid: Performing Ad Hoc Web Reporting with a VBScript 5.0 Class Object


A flexible, customizable grid for displaying data is a useful tool for ASP developers. It allows Web visitors to customize their view of your data. This article takes the data grid presented in "Ad Hoc Web Reporting with ADO 2.0" by John Papa and Charles Caison (MIND, December 1998) and adds handy features such as a finds feature that supports multiple finds and a mode for adding and editing records. This version also improves response time by allowing asynchronous record download and it componentizes the code so it can be used as a standalone VBScript class object that can be reused in other pages.

Randall Kindig

MSDN Magazine July 2000

Empty Website Data Source windown


Hi all,

I am Visual Web Developer user and facing a problem when I am creating a local report (.rdlc) file.

I am using Business objects as the Data Source for this report. It was working perfectly until all the items in the Website Data Source window suddenly "disappeared". The "Add New Data Source" button on this window is also disabled. Now the window is just like a blank box only. And I can't continue working with the report file like this...

I have tried undoing what I did before but it does not help at all...

Any reason for this to happen? There is no sign or something at least indicating what is wrong.

Please help.


 ps: found a similar thread in this forum but not solved

show data in grid view error Arithmetic operation resulted in an overflow.



i have a table there is 17 columns in 17 column 3 are number and other are varchar . when i try to display all data of that column error occures.

one more intersting think is when i try to display 6 column then grid show there data an no more error occures. 

when i run my project this error occures in grid view

Arithmetic operation resulted in an overflow. 

The report cannot be opened because the data source associated with it is not a report model.


i tried to open a report i created in sql business intelligence development studio in the report builder in wss3 and it gave me this error:

Microsoft.ReportingServices.ReportBuilder.ReportModel.Report: The report 'http://servername:port#/Reports/report.rdl' cannot be opened because the data source 'http://servername:port#/DataSource Library/datasource.rsds' associated with it is not a report model.

This report was not created in Report Builder. Try opening this report in Report Designer instead.

can i fix this so i can open my reports in report builder?

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend