hi,
I am using CLR stored procedure having my dmx query.I need to exeute that Query and get the resultset as dataset how to do this
Here is my code sample
namespace PredictPerformance
{
class perf
{
public static dataset getPredict(int StudID)
{
----
return ds;
}
}
}
Execute the proc:
SELECT PredictPerformance.getPredict(1) FROM [Stud_Model]
how to get the result
Thanks,
Karthik.

How to exeute dmx query?
fruce
If your dataset contains a single table, then it is much better to change your stored procedure to return a DataTable object rather than a dataset.
If you really need a data set (i.e. with the current syntax), the stored procedure will return a single text cell containing the XML serialization of the dataset object. You should be able to restore the dataset by loading it in a client application
Whoisit
hi,
this is my test code.
public static DataTable GetPreparedTable()
{
System.Data.DataTable results = new System.Data.DataTable();
results.Columns.Add("A", typeof(int));
results.Columns.Add("B", typeof(string));
if (Context.ExecuteForPrepare)
{
// If preparing, return just the schema with no data
return results; //return "false";}
else{
//Otherwise return data object[] row = new object[2];row[0] = 1;
row[1] =
"A";results.Rows.Add(row);
row[0] = 2;
row[1] =
"B";results.Rows.Add(row);
return results; //return "true";}
}
When i execute this
SELECT
ContractPerformanceModels.GetPreparedTable() FROM [Test_Model] its giving me"Prepare is not safe during execution of the GetPreparedTable stored procedure." error.
I dont know whats the problem.pls help.
karthik
UltimateSniper
Hi
Please try the following:
1. Change the class definition "class perf" to "public class perf" to make it public outside the namespace.
2. Change your getPredict(int StudID) to return a DataTable.
3. Execute the query
SELECT PredictPerformance.getPredict(1) FROM [Stud_Model]
from SQL Server Management Studio
You should see one column with a nested table.
Hope this helps
alibeau
I think you should be able to start SQL studio and select "New DMX query"
-Dennis
EoF
Your code handles correctly the Prepare execution (with Context.ExecuteForPrepare).The server is, however, not aware of this in the pre-execution phase. You should decorate your function declaration with a a special attribute, like below
[SafeToPrepareAttribute(true)]
public static DataTable GetPreparedTable()
Note that the SafeToPrepare attribute is part of the Microsoft.AnalysisServices.AdomdServer namespace, so you need to add a reference to this assembly.
lalala--la
hi Bogdan,
its works fine with me.
Thanks a lot.
GiriKrishna
hi,
Thanks for your reply.But I dnt Know how to fill data in my data table.could you pls help.
Thanks,
Karthik.