Solved

c# execute view

Posted on 2009-05-19
3
863 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
  • 2
3 Comments
 
LVL 25

Expert Comment

by:Lee Savidge
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
thanks
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now