What's wrong with my SqlCommand?
- From: "Jason Huang" <JasonHuang8888@xxxxxxxxxxx>
- Date: Thu, 14 Dec 2006 11:50:48 +0800
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, 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
.
- Follow-Ups:
- Re: What's wrong with my SqlCommand?
- From: Christof Nordiek
- Re: What's wrong with my SqlCommand?
- Prev by Date: Re: Package and deploy in .NET
- Next by Date: Re: Please help asap.
- Previous by thread: ExecuteReader and ExecuteNonQuery
- Next by thread: Re: What's wrong with my SqlCommand?
- Index(es):