in my method i have the following lines:
|
at the linke where i call BeginTransaction() it throws Invalid Operation exception
the following video shows what is excatly happening: http://www.youtube.com/watch?v=Sc5c40WT89M
thanks
|
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sam HobbsPosted Oct 6, 2010, 6:19 AM
Gomathi PalaniswamyPosted Oct 6, 2010, 12:50 AM
refer the below article.
http://www.dotnetspider.com/resources/4459-How-use-SqlTransaction-object-C.aspx
Rakesh JhaPosted Oct 6, 2010, 12:32 AM
I suppose you are missing commandtext property.
SqlConnection con = new SqlConnection(@"server=servername; database=dbname; user id=username; password=password;");
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "procedure"; <---- put your procedure name here
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = con;
SqlTransaction trn = con.BeginTransaction();
hope it will help, also you can change connection string like above given.