Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

c# execute view

Posted on 2009-05-19
3
Medium Priority
?
870 Views
Last Modified: 2013-12-17
I C# It is possible to execute a SQL storedprocedure using the following code

DbCommand dbCommand = db.GetStoredProcCommand("StoredProcedureName");

Does anybody know how I can I execute a grad the data from a view.

specifical the SQL server system view for master.sys.sysdatabases.

for example

DbCommand dbCommand = db.GetViewCommand("master.sys.sysdatabases");
0
Comment
Question by:Mr_Shaw
[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
3 Comments
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 24423671
Hi,

You don't execute a view in the way you do with a stored procedure. You just select * from the view and it will return everything.

See here:

http://msdn.microsoft.com/en-us/library/9hy8csk1.aspx

Cheers,

Lee
0
 
LVL 25

Accepted Solution

by:
Lee Savidge earned 2000 total points
ID: 24423680
In that example, the queryString string variable, replace with

select * from insertViewNameHere

and it will do what you want.

Cheers,

Lee
0
 

Author Closing Comment

by:Mr_Shaw
ID: 31597511
thanks
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

660 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