Link to home
Start Free TrialLog in
Avatar of MHDMarkei
MHDMarkei

asked on

How can I set ANSI-WARNINGS OFF using DELPHI and ADO for a connection

I am working on a DELPHI5 application that was ported from SQL 2000 to 2005. There are a huge number of INSERT/UPDATE statements explicitly coded within the application using TADOQuery as well as updates being performed via DBGRIDS etc. The application is experiencing a number of run-time errors due to strings exceeding the defined capacity which I am aware is due to ANSI-WARNINGS ON. How can I easily overcome this with the minimum of coding change? Is there a something that can be done as part of the Connection string or after connection that would apply to all SQL executed within? or do I have to bite the bullett and change all SQL accordingly? I've experimented with running a stored procedure to SET ANSI-WARNINGS OFF after connection but this has not worked. Help.
Avatar of Mike Littlewood
Mike Littlewood
Flag of United Kingdom of Great Britain and Northern Ireland image

I didn't think you could do this from within a query in Delphi.
I believe this needs to be done on the database itself but I could be wrong.
The only time i have ever seen it done is via a query that is running a stored procedure on the database. But this obviously means the SQL is at database level and not within an application.
ASKER CERTIFIED SOLUTION
Avatar of kenpem
kenpem
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sorry... edit to previous post... that query fired at the server must of course be SET ANSI_WARNINGS OFF, not ON!

Also as a comment: in general, I personally recommend leaving warnings ON and fixing any underlying causes, but that may not be an option in your situation.
Avatar of ThievingSix
Put a Try except clause?

Try
<code here>
Except
//blank
end;

You'll still get errors when running from the ide but from a compiled app you shouldn't.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I object... There are several answers and a couple good ones.

Without further clarification of why nothing provided any assistance from the asker,  then this Q should not be just closed with points refunded.

John
Repeated...

I object... There are several answers and a couple good ones.

Without further clarification of why nothing provided any assistance from the asker,  then this Q should not be just closed with points refunded.

John
He split the points...he's not asking for a refund anymore.
Avatar of modus_operandi
modus_operandi

Force accepted.
modus_operandi
EE Moderator