Solved

c# execute view

Posted on 2009-05-19
3
866 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
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 500 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
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 information from SQL Server on Database, Connection and Server properties

828 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