Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

(C# and ADO.NET) ExecuteNonQuery() problem

Status
Not open for further replies.

gicio

Programmer
Jun 18, 2002
39
DE
Hi there!

how I can find out why ExecuteNonQuery() return 0 and not 1 by submit?
at this moment I see no chance to know why my query isn't submited.


thx


gicio
 
I'd suggest making use of a standard try {} catch {} scoping and output (either to the form or as a MessageBox.Show()) the nature of the Exception that is caught.
I hope that this helps - it's proved useful on my learning curve to better understand why SQL statements are failing.
Steve
 
You might also want to paste your SQL into QueryAnalyzer and make sure that it's OK.

Chip H.
 
Or SQL Plus, or Access Query, or whatever....he might not be running SQL Server.
 
The try / catch and display of caught Exception should give some clues regardless of the database sitting underneath the application code.
Let us know how you get on. :)
Steve
 
Hi,
thx for support me!

I try

try/catch... but code not go into the catch although ExecuteNonQuery() return 0.
I don't know why.

I change my update SQL query from:

m_strSQL = "UPDATE Car SET CarID = ?, Manufacture = ?,Color = ?, Hp = ?, Displacement = ?, Price = ?, Model = ?, SaleContractID = ? WHERE CarID = ? AND Manufacture = ? AND Color = ? AND Hp = ? AND Displacement = ? AND Price = ? AND Model = ? AND SaleContractID = ?";


to:

m_strSQL = "UPDATE Car SET CarID = ?, Manufacture = ?, Color = ?, Hp = ?, Displacement ?, Price = ?, Model = ?, SaleContractID = ? WHERE CarID = ? AND Manufacture = ? AND Color = ? AND Hp = ? AND Displacement = ? AND Price = "? AND Model = ?";



AND it's works now!!!

;)
 
Its odd that it is working for you now. You have (3) double quotes in your new statement.
 
upps...
I see!!

;)

m_strSQL = "UPDATE Car SET CarID = ?, Manufacture = ?, Color = ?, Hp = ?, Displacement ?, Price = ?, Model = ?, SaleContractID = ? WHERE CarID = ? AND Manufacture = ? AND Color = ? AND Hp = ? AND Displacement = ? AND Price = ? AND Model = ?";

thats now correct!


thx


gicio
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top