|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
What's wrong with my SqlCommand?In my codes: ======================================= myConn.Open(); SqlTransaction MyTrans= myConn.BeginTransaction(); SqlCommand myCommand = new SqlCommand("ZZZ15UserLog",myConn); myCommand.CommandType= CommandType.StoredProcedure; SqlDataReader myReader; myCommand.Transaction=MyTrans; try { myCommand.ExecuteReader(); MyTrans.Commit(); } catch { } ======================================== That will result in some error, however, if I change the ExecuteReader() to ExecuteNonQuery(), it will be fine. Would someone tell me what have I done wrong with my code? Thanks for help. Jason
Show quote
Hide quote
"Jason Huang" <JasonHuang8***@hotmail.com> schrieb im Newsbeitrag <snip>news:OkRmKMzHHHA.3872@TK2MSFTNGP06.phx.gbl... > Hi, > > In my codes: > ======================================= > myConn.Open(); > SqlTransaction MyTrans= myConn.BeginTransaction(); > > SqlCommand myCommand = new SqlCommand("ZZZ15UserLog",myConn); > myCommand.CommandType= CommandType.StoredProcedure; > SqlDataReader myReader; > > myCommand.Transaction=MyTrans; > try > { > myCommand.ExecuteReader(); > MyTrans.Commit(); > } > catch { } > ======================================== > > That will result in some error, What is the error? The message and the type of the exception will give information about what went wrong. If ExecuteReader failed but ExecuteNonQuery not, then maybe the procedure doesn't return any result.
Other interesting topics
SocketException: Too many open files - can't understand why though?
Question about Garbage Collection with Framework 1.0 and 2.0 Package and deploy in .NET Background worker tasks sequentially? Temporarily give the current user Local Admin rights VS Service Packs are too far apart Problem with application trying to read data from a network stream when the socket is closed Where is System.Reflection.dll assembly? HttpRepsone.OutputStream & HttpWebResponse.GetResponseStream() timer... |
|||||||||||||||||||||||