By using cursor i want to make one virtual table. and after that using function i want to use that virtual table format and pass value of original table and then.. i show.. virtual table.. into output..
views:
38answers:
1
+1
A:
Yes. But you can also use SqlDataReader to accomplish the same. Note that you might have to create a new connection from the embedded c# (instead of using SQLContext).
string queryString = "SELECT OrderID, CustomerID FROM dbo.Orders;";
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
SqlCommand command = new SqlCommand(queryString, connection);
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
var c1 = reader[0];
var c2 = reader[1];
....
}
reader.Close();
}
}
Check this for an example of how to wrap this code inside a Table-Valued-Function.
Nestor
2009-11-09 23:24:19
can u give me exmple how? i am new user.. that's why?
Sikender
2009-11-09 23:31:05
I've added a bit of pseudo code to help you out.
Nestor
2009-11-09 23:48:32
Note that if you use an external (loopback) connection and not the context connection you will run into all sort of transactional incosistencies, as the 'select .. from Order' will execute under a different transaction context than the caller.
Remus Rusanu
2009-11-10 00:36:51
have you any example to made it above explaination?
Sikender
2009-11-10 01:29:38