Hi,
I have been trying to find out how to update a table in SQL Server 2005 using (CLR).
This is my class
public static void UpdateDatabase()
{
string Name;
using (SqlConnection conn =
new SqlConnection("context connection = true"))
{
conn.Open();
SqlCommand cmd = new SqlCommand(
"SELECT A,B FROM dbo.Table", conn);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Name = reader.GetString(0);
string Query = String.Format(
"UPDATE Table SET A = '{0}1' WHERE A = '{0}'",A);
SqlCommand cmdupd = new SqlCommand(
Query, conn);
SqlContext.Pipe.ExecuteAndSend(cmdupd);
reader.NextResult;
}
reader.Close();
conn.Close();
}
This does not work, can somebody help ?
Thanks
I have been trying to find out how to update a table in SQL Server 2005 using (CLR).
This is my class
public static void UpdateDatabase()
{
string Name;
using (SqlConnection conn =
new SqlConnection("context connection = true"))
{
conn.Open();
SqlCommand cmd = new SqlCommand(
"SELECT A,B FROM dbo.Table", conn);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Name = reader.GetString(0);
string Query = String.Format(
"UPDATE Table SET A = '{0}1' WHERE A = '{0}'",A);
SqlCommand cmdupd = new SqlCommand(
Query, conn);
SqlContext.Pipe.ExecuteAndSend(cmdupd);
reader.NextResult;
}
reader.Close();
conn.Close();
}
This does not work, can somebody help ?
Thanks