473,659 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1227
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********@wid getinc.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*****@houdin i.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
11508
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
6401
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 configuration: RAID 1 array (2 disks) Operating System Windows Server 2003 RAID 1 array (2 disks) Database Logs RAID 10 array (4 disks) Database Data
0
1681
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 occur when I try to drop a table. boo:/var/backups# su postgres pg_dump rj > /var/backups/rj.dump pg_dump: FATAL 2: open of /var/lib/postgres/data/pg_clog/0004 failed: No such file or directory pg_dump: lost synchronization with server,...
9
2135
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 the database based on some enriched description of the tables (from which it also generates the SQL code to create them). My application connects to the database using the socket-level frontend/backend protocol rather than providing a...
0
2122
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 tables to an external MS-SQL datasource, through ODBC. I can establish the ODBC link, I can link the tables in a new MS Access database (File -> Get External Data -> Link Tables...), I can view the structure of the linked table(s), I can querie...
0
2682
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 => "IErrorInfo.GetDescription failed with E_FAIL(0x80004005)." QUERY: " SELECT "+ " (select Quantity from Items_Detail idt "+
7
2720
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 relation 149064743 failed 2004-04-14 12:23:32 ERROR: Relation "tmp_table1" does not exist 2004-04-14 12:23:32 ERROR: Relation "tmp_table1" does not exist So turn on debugging options and have that's what i got:
4
11651
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: ************************************************************************************ ODBC -call failed. ORA-01017: invalid username/password; logon denied (#1017) Driver's SQLSetConnectAttr failed IM006 0 Driver's SQLSetConnectAttr failed...
7
4353
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. First it says "Please wait a moment while queries are run. The report will open automatically.Click ok to continue. When I hit "OK", there appears an "Action Failed" dialogue box, which has only one activated button called "Halt", which says the...
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8330
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8850
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6178
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.