Sql server 7
There will be times when the user will not be required to supply a value for
the calling asp script that pass values to an sql server Sp.
How can I handle these null or empty values so I do not generate an error
for the code below....
1. Should I rewrite the sql server SP to handle the null values...
2. or should I replace the null and empty values with a dummy value.
----------------------------------------
Here is an example of my calling code:
---------------------------------------
set oConn = GetConnection()
Set oCmd = GetStoredProced ure(oConn,"sp_a dduser1")
oCmd.Parameters .append oCmd.CreatePara meter("u_id", adVarChar,
adParamInput,50 ,sID)
oCmd.Parameters .append oCmd.CreatePara meter("u_name", adVarChar,
adParamInput,50 ,sEmailName)
oCmd.Parameters .append oCmd.CreatePara meter("u_Nation ID", adVarChar,
adParamInput,12 ,sNationID)
set oReturn = oCmd.CreatePara meter("u_id", adInteger, adParamOutput)
oCmd.Parameters .append oReturn
oCmd.execute()
if oReturn.value=-1 then
'//Code
Else
'//Code
end if
------------------
STORED PROC
------------------
CREATE Procedure sp_adduser1
@u_name varchar(50),
@u_NationID int,
@u_id int output
As
set nocount on
if not exists(select u_id from t_user where u_name=@u_name)
begin
INSERT INTO t_user(u_name, u_NationID)
VALUES (@u_name@u_Nati onID)
select @u_id=@@identit y
end
else
select @u_id=-1
return
GO 1 1353
<ja***@catamara nco.com> wrote in news:OxRihcYoEH A.2900
@TK2MSFTNGP12.p hx.gbl: How can I handle these null or empty values so I do not generate an error for the code below....
Top of my head, the easiest way would be to use IsNull in the sproc...
INSERT INTO t_user(u_name, u_NationID)
VALUES (IsNull(@u_name ,''),IsNull(@u_ NationID,'')) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Johannes Hansen |
last post by:
What are the best practice on handling an exception caused by a Dispose
method when its called from inside a loop? Wrap the entire loop in a
try-catch or do the try-catch on each iteration to get as many of the object
Disposed as possible?
Take the following example:
Bitmap bmpArray = ... // Some fancy bitmap array.
try
{
|
by: Matt Kruse |
last post by:
http://www.JavascriptToolbox.com/bestpractices/
I started writing this up as a guide for some people who were looking for
general tips on how to do things the 'right way' with Javascript. Their code
was littered with document.all and eval, for example, and I wanted to create
a practical list of best practices that they could easily put to use.
The above URL is version 1.0 (draft) that resulted. IMO, it is not a
replacement for the FAQ,...
|
by: Sandy |
last post by:
Hello -
I read an interesting article on the web wherein the author states he
doesn't handle too many errors at page level, but handles them at the
application level. He further goes on to show how error logging can be
incorporated using a Sql Server log with an additional text log in case Sql
Server was down.
My inclination after reading the article is to use Try-Catch-Finally as
little as possible (tends to slow things if you have...
|
by: James Radke |
last post by:
Hello,
I am looking for guidance on best practices to incorporate effective and complete error handling in an application written in VB.NET. If I have the following function in a class module (note that this class module represents the business layer of code NOT the gui layer):
Public Function Test(ByVal Parm1 As Integer, ByVal Parm2 As Integer) As SqlDataReader
' Declare the SQL data layer class
Dim oSQL As New...
|
by: RonL |
last post by:
What is the recommended best technique for handling errors/exceptions in
ASP.Net. I've read about the following techniques:
1. Try/Catch
2. Page_Error
3. Application_Error in the glabal.asax
4. Custom errors in Web.Config.
| |
by: csgraham74 |
last post by:
Hi guys,
Basically i have been developing in dotnet for a couple of years but
ive had a few issues in regards to error handling.
For example - I have a class that i call passing in a stored procedure
and connection string as a path. My method returns a dataset. In my SP
i have an output parameter which tells me whether the SP select is
successful or not. If i get a error code passed back then i throw an
exception this then returns...
|
by: TEK |
last post by:
Hello
I'm having some questions regarding the implementation of
IPropertyChanged interface.
Status:
I have the basic stuff up and running, and on every property change I
get a call to my OnPropertyChanged method with the correct property
name.
|
by: =?Utf-8?B?QmlsbHk=?= |
last post by:
asp.net 2.0 vs2005
What is best practice for exception handling on a website in vs2005?
I was going to catch errors in application on_error event, log them to the
event log, then send users to an error page. But looking at the event log,
asp.net 2.0 logs those errors anyways, with more detail than i cen get from
the exception object. So is there any point logging them to the event log, is
it jsut better to let .net do this and get the...
|
by: stephen.diverdi |
last post by:
I have a question about what's the best way to handle something in C++
without a lot of redundant code and void*s because I don't seem to be
able to avoid them both. I've run into it before and always sort of
hacked something together, but I'd really prefer a more elegant
solution.
I have a parameter struct that I store some values of varying type in:
struct params_t
{
|
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...
|
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,...
| |
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...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |