v-wywang
9/7/2007 3:21:00 AM
Hello Manjree,
I'm sorry to say what you need is not possible in Stored Procedure.
However, the correct way to achieve that is to create a dynamic T-SQL query
in SQLCommand.
In Stored Procedure, what we can do is pass the value to Stored Procedure.
As far as I know, we cannot pass column name, operator to generate query
and execute on SQL Server.
I suggest you may create a dynamic SQL query (as below) to achieve this.
Such as:
String^ SQLquery=System::String::Format("SELECT {0} FROM Supplier JOIN
Sample ON Supplier.supplierID = Sample.supplierID WHERE ({1})",
"Supplier.supplierID, sampleID, amount","Supplier.supplierID=1");
System::Data::SqlClient::SqlCommand^ scd=gcnew
System::Data::SqlClient::SqlCommand();
scd->CommandText=SQLquery;
scd->CommandType=System::Data::CommandType::Text;
...
Hope this helps. Please let me know if you have any more concern. I'm glad
to assist you.
Have a great weekend!
Best regards,
Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.