473,387 Members | 1,903 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,387 software developers and data experts.

Error codes for sql server?

Roy
Hey all,
I wish to implement a "Try..." block into my web app (which is
basically an editable datagrid) to display appropriate error pages to
my users. Basically, the two main error's are that the request times
out while talking to sql server or that the database admin kills the
process. Does anyone know what error codes those are so that I might
insert them into catch exceptions block or direct me to a
link/reference where they might be located?

Thanks,
Roy

Nov 19 '05 #1
2 1307
If you want to dink with this, try this C# program:

class Class1
{
[STAThread]
static void Main(string[] args)
{
//Blank sa for example only (not a good idea on a production db)
string connString = @"server=(local);database=pubs;UID=sa;PWD=;";
string cmdText = @"UPDATE Authors SET au_lname = au_lname";

SqlConnection conn = new SqlConnection(connString);
SqlCommand cmd = new SqlCommand(cmdText, conn);

//For admin killing process
cmd.CommandTimeout = 0;

//For timeout
cmd.CommandTimeout = 1;

try
{
conn.Open();
cmd.ExecuteNonQuery();
}
catch(Exception ex)
{
//Breakpoint location
string typ = ex.GetType().ToString();
}
finally
{
conn.Dispose();
}
}
}

Before running this program, run the following against the pubs database:

BEGIN TRAN

UPDATE AUTHORs SET au_lname = au_lname
WAITFOR DELAY '00:02:00'
UPDATE AUTHORs SET au_lname = au_lname
COMMIT

What you will find is the same exception is thrown each time:

GetType() = System.Data.SqlClient.SqlException

The difference is the message:

Timeout:
"Timeout expired. The timeout period elapsed prior to completion of the
operation or the server is not responding."

Admin killing process:
"A severe error occurred on the current command. The results, if any,
should be discarded.\r\nThe transaction has been terminated.\r\nThe statement
has been terminated."

You can use the messages, but realize that other fatal errors will cause the
same exception message as an admin killing a process. This is good enough,
however, to pass a message on to the user.

I have not played with inner exceptions to see if there are any in either
case (my guess is no, but it is worth an experiment).

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"Roy" wrote:
Hey all,
I wish to implement a "Try..." block into my web app (which is
basically an editable datagrid) to display appropriate error pages to
my users. Basically, the two main error's are that the request times
out while talking to sql server or that the database admin kills the
process. Does anyone know what error codes those are so that I might
insert them into catch exceptions block or direct me to a
link/reference where they might be located?

Thanks,
Roy

Nov 19 '05 #2
Roy
Thanks for the great assistance Greg, it's appreciated!

As far as an inner exception for the admin killing, nope, there isn't.

Nov 19 '05 #3

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

Similar topics

8
by: Shane Groff | last post by:
I know this is a recurring discussion (I've spent the last 3 days reading through threads on the topic), but I feel compelled to start it up again. After reading through the existing threads, I...
3
by: Jocelyn Duhaylungsod | last post by:
I have been getting the following server errors sporadically while downloading excel, csv or xml file. Internet Explorer cannot download <file name> from <IP address> "The server returned an...
6
by: Tatsuo Ishii | last post by:
Hi, Does anybody know how I can get error codes using psql? I know that I could get error codes from server log or using libpq function. I just could not figure out a way to display them in...
0
by: HKSHK | last post by:
This list compares the error codes used in VB.NET 2003 with those used in VB6. Error Codes: ============ 3: This Error number is obsolete and no longer used. (Formerly: Return without GoSub)...
4
by: fatboySudsy | last post by:
Hi, I have constructed a client program that has given me some error codes that i just cannot see. I was wondering if a different set of eyes with much more experience than me could help me out. ...
3
by: Bobby | last post by:
Hi I'm using Access 2003 with SQL server 2000, linked via ODBC. Can anybody tell me how to capture SQL error codes in Access? If this is not possible, is there any way I can simply turn off SQL...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
5
by: =?GB2312?B?17/HvyBaaHVvLCBRaWFuZw==?= | last post by:
Hi, I would like to have someone comments on what's the best practice defining error codes in C. Here's what I think: solution A: using enum pros: type safe. better for debug (some debugger...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.