I have a SQL Server stored procedure:
SET NOCOUNT ON
EXECUTE sp_configure 'Show Advanced Options', 1
RECONFIGURE
EXECUTE sp_configure 'Ad Hoc Distributed Queries', 1
RECONFIGURE
SELECT UserName, LoggedState, InteractionId, InteractionType
FROM
OPENROWSET('SQLNCLI'
,'Server=USER-PC\SQLEXPRESS;Trusted_Connection=yes;database=XXX'
,'EXECUTE dbo.[XXX]')
When I run it in SQL Server Management Studio, I got this result:

My question
I need to read data from a table.
My problem
This data is not in the output parameters. That is why I could not read them.
What i tried
string vmpgraph = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
SqlConnection Graphsqlcon = new SqlConnection(vmpgraph);
SqlCommand GraphCmd = new SqlCommand("storedProcedureName", Graphsqlcon);
SqlParameter tdate = new SqlParameter();
GraphCmd.CommandType = CommandType.StoredProcedure; ;
SqlDataAdapter DAGraph = new SqlDataAdapter(GraphCmd);
DataSet DSGraph = new DataSet();
DSGraph.Clear();
DAGraph.Fill(DSGraph);
DataTable DTgraph = new DataTable();
DTgraph = DSGraph.Tables[0];
It is right? If not, what should I do, please?
I could not verify my code on a real database, because I do not have a database yet.
source
share