473,396 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Failed SQL Queries

Hi All,

Help please! I have a formview on my page and I've created an update
command of the form:

"update [table] set valuex=@valuex, valuey=@valuey where
valuez=@valuez"

which I can get to execute....sort of. The problem is, if it failed I
want to know exactly what the database was trying to execute but all I
get is a "your query failed, so suck on it" type of message with only
the vaguest direction of what could be the problem.

How can I "trap" the exception and create my own custom message that
tells me the exact query string?

tia,
rts

ps: extremely new to asp.net - I know asp classic like the back of my
hand but this is a whole new world.

Nov 6 '06 #1
4 1212
Anyone? Anyone?

The lack of response is leading me to believe that this is impossible
(and a shortcoming of .NET)

Anyone?
Rex the Strange wrote:
Hi All,

Help please! I have a formview on my page and I've created an update
command of the form:

"update [table] set valuex=@valuex, valuey=@valuey where
valuez=@valuez"

which I can get to execute....sort of. The problem is, if it failed I
want to know exactly what the database was trying to execute but all I
get is a "your query failed, so suck on it" type of message with only
the vaguest direction of what could be the problem.

How can I "trap" the exception and create my own custom message that
tells me the exact query string?

tia,
rts

ps: extremely new to asp.net - I know asp classic like the back of my
hand but this is a whole new world.
Nov 7 '06 #2
On 6 Nov 2006 15:02:59 -0800, "Rex the Strange"
<ro********@widgetinc.comwrote:
>Hi All,

Help please! I have a formview on my page and I've created an update
command of the form:

"update [table] set valuex=@valuex, valuey=@valuey where
valuez=@valuez"

which I can get to execute....sort of. The problem is, if it failed I
want to know exactly what the database was trying to execute but all I
get is a "your query failed, so suck on it" type of message with only
the vaguest direction of what could be the problem.

How can I "trap" the exception and create my own custom message that
tells me the exact query string?

tia,
rts

ps: extremely new to asp.net - I know asp classic like the back of my
hand but this is a whole new world.
This message should be in a T-SQL forum, which is why no one has
answered it here.

Design your SQL sproc such that you detect the error there and pass back
the result as an integer variable from your sproc. to your ASP.NET code.
It will be the SQL RETURN value.

DECLARE @QueryResult INT

// do your update ...

RETURN @QueryResult

If you use RETURN like this you will need to explicitly set the
@QueryResult depending upon whether your UPDATE works or not. But you
don't need to do this. Most people don't. The RETURN value is naturally
available from a sproc anyway whether or not you return a value (as
above) or even use the RETURN keyword.

The return result from a query that succeeds should be 1 - any failed
query will naturally return a non-zero value (even if you don't declare
one in your sproc). Look-up these sproc return values in SQL books
online to make sense of them. Likewise lookup RETURN in SQL books
online.

Lookup RAISERROR, WITH SETERROR | LOG | NOWAIT, @@ERROR as well. This
should be covered in any good book on T-SQL but I guess there are no v.
good comprehensive books on new features added to SQL-2005 yet. Viera's
book on SQL 2000 remains excellent (if well out of date) but I haven't
read his book on SQL 2005. Errors are covered in pp 387-405 of Viera's
SQL 2000 book. (his new Professional SQL 2005 book is due any day now)

Post your question in a T-SQL forum to get a better explanation of SQL
error handling.
Nov 8 '06 #3
On Wed, 08 Nov 2006 06:37:00 GMT, Jasbird <Ja*****@houdini.comwrote:
>The return result from a query that succeeds should be 1 - any failed
query will naturally return a non-zero value
Apologies for the confusion here, my mistake.

The return value (for a good query) is naturally zero not 1
Nov 8 '06 #4
Post your question in a T-SQL forum to get a better explanation of SQL
error handling.
Sorry, I wasn't aware I was posting to the wrong group. I saw this as
an asp.net issue which is why I posted it here.

Can you recommend a good T-SQL forum?

Nov 8 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: craig | last post by:
RH 9.0 user mysql command /usr/sbin/mysqld mysql is being loaded at boot. the previous is listed when I check what process are running with < ps -aux > however: $ ./bin/mysqladmin version
4
by: Morgan Leppink | last post by:
Hey all - We are running SQL 2000 with ALL available service packs, etc. applied. We just built a brand new database server, which has dual 2Ghz XEONs, 2GB memory, and the following disk...
0
by: news.paradise.net.nz | last post by:
My database appears to be a little corrupted, so far it's running along 99% ok, but i am getting some strange results. Primarily i can't back it up because of the following error. Similar errors...
9
by: Alejandro Forero Cuervo | last post by:
Hello. I'm new to PostgreSQL and I'm using it for some project. I am currently creating an entity engine that provides a web interface, which is oriented towards end users, to...
0
by: Cunfshon | last post by:
I wrote about this one a while ago, and got a few responces, but nothing resolved the issue. Figured I'd give everyone one more crack at it. I have an established MS Access database using linked...
0
by: Arif | last post by:
In my C# application all queries runs well both with MS Access and SQL Server databses. But only the following query runs well on SLQ Server2000 but with MS Access gives error =>...
7
by: Juris Krumins | last post by:
I have a problem with postgresql tables. periodicaly, I would say frequently about 5-10 time per hour i have such errors in my server log file: 2004-04-14 12:23:32 ERROR: cache lookup of...
4
by: alegria4ever | last post by:
I have an Access 2000 database that links several tables from Oracle 9. For some reason or another, one of our user repeatedly gets the following error when accessing queries within this database:...
7
jinalpatel
by: jinalpatel | last post by:
I have a report which is based on a macro. Macro is serieas of open queries and a single open report query. When I run this report from my switchboard form it gives me the following series of errors....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.