c# execute view

Posted on 2009-05-19
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");
Question by:Mr_Shaw
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
LVL 25

Expert Comment

by:Lee Savidge
ID: 24423671

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:


LVL 25

Accepted Solution

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

select * from insertViewNameHere

and it will do what you want.



Author Closing Comment

ID: 31597511

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

738 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