|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Get SQL statement in a catch(SqlException)I'm debugging an application using log4net. When a SQL statement fails
it is logged. One of the messages is Line 1: Incorrect syntax near ')'. but I'm not sure which SQL command is executed. Can I get the complete SQL command send to the database server from an SqlException? Hi,
No, I don't think you can. However, nothing prevents you to log each command text before executing it. -- Show quoteMiha Markic [MVP C#] RightHand .NET consulting & development www.rthand.com Blog: http://cs.rthand.com/blogs/blog_with_righthand/ <martijndemun***@gmail.com> wrote in message news:1145878929.387871.241670@g10g2000cwb.googlegroups.com... > I'm debugging an application using log4net. When a SQL statement fails > it is logged. One of the messages is > > Line 1: Incorrect syntax near ')'. > > but I'm not sure which SQL command is executed. Can I get the complete > SQL command send to the database server from an SqlException? > Well I'm using a dataset with a dataadapter. I call the
dataadapter.update method and I can't tell wich sql commands are executed. Is there a way to find out which SQL statements are executed when I call the update methode? thanks, Martijn just get SqlDataAdapter.UpdateCommand, could you please precise your
probleme and paste your code here? The problem is that a paramater doesn't seem to be parsed in some
circumstances and I can't figure out which paramater and why. I would like to see the parsed SQL statement sent to the server when an sqlexception is thrown. Then log all three commands (update, insert and delete).
If they are not too complicated it should be obvious why they fail by looking at them. -- Show quoteMiha Markic [MVP C#] RightHand .NET consulting & development www.rthand.com Blog: http://cs.rthand.com/blogs/blog_with_righthand/ <martijndemun***@gmail.com> wrote in message news:1145884695.875315.110410@y43g2000cwc.googlegroups.com... > Well I'm using a dataset with a dataadapter. I call the > dataadapter.update method and I can't tell wich sql commands are > executed. Is there a way to find out which SQL statements are executed > when I call the update methode? > > thanks, > > Martijn > If you're using MS SQL Server could you try SQL Profiler?
Show quote "martijndemun***@gmail.com" wrote: > Well I'm using a dataset with a dataadapter. I call the > dataadapter.update method and I can't tell wich sql commands are > executed. Is there a way to find out which SQL statements are executed > when I call the update methode? > > thanks, > > Martijn > > |
|||||||||||||||||||||||