Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 872
  • Last Modified:

c# execute view

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
Mr_Shaw
Asked:
Mr_Shaw
  • 2
1 Solution
 
Lee SavidgeCommented:
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
 
Lee SavidgeCommented:
In that example, the queryString string variable, replace with

select * from insertViewNameHere

and it will do what you want.

Cheers,

Lee
0
 
Mr_ShawAuthor Commented:
thanks
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now