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

Sqlserver2005: How to get the error message thrown from Storedproc to C#

40
hi

i had created as SP to delete the record using where condtn.if the record doesnt exists the SP will throw an error as "No such record found" and return 0 .

But my c# code gets -1 rows affected from the sql.its ok.
My problm is how to get the "No such record found" from sql to c#.
Expand|Select|Wrap|Line Numbers
  1. ALTER PROCEDURE SP_deleteUserMaster
  2. @LoginId nvarchar(30)
  3. AS
  4. begin
  5. set nocount on
  6. declare @ncnt int
  7. select @ncnt=(select count(*)from UserMaster where LoginId=@LoginId)
  8. if (@ncnt>0)
  9.  
  10. begin
  11. DELETE FROM UserMaster WHERE LoginId=@LoginId
  12. end
  13. else
  14. raiserror('No record found',10,1)
  15. end
  16. RETURN
  17.  
thank u
Dec 18 '07 #1
1 2368
moggaa
13
hi

it's easy to found it

when you try your stord procedure in your Query Analyzer you know your erorr
but when you run it your code but


Try
'your stored procedure here
Catch ex As Exception
Response.Write(ex.Message.ToString)
End Try

but this code Vb not C# but it's not different

then you will know the error message

if any problem send me social1e@yahoo.com

Subject error from the scripts site

Eng. Maged
Dec 18 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: ahaupt | last post by:
Hi all, I'm currently writing a load of class libraries, but not the main application iteslf. I want to provide some method for reporting errors back to the main application. At the moment...
6
by: Leo R | last post by:
Hi all, If an error occurs in an aspx-page, you can configure the web.config in a way that the user automatically navigates to a certain page (e.g. error.aspx). My question: is it possible to...
1
by: D A H | last post by:
I have gotten the same exception in multiple projects. I have solved the underlying problem. My question is if anyone knew of a setting that would cause this exception to be thrown. A...
2
by: rob lynch | last post by:
I have been trying to get a grasp on how I can use a sqlserver storedproc as the UpdateCommand of a Dataview. The control (datview / SqlDatasource / Edit control) works great when you supply it...
1
by: Khodr | last post by:
Hi everyone, I am calling an Oracle StoredProc that returns a CLOB data type value as an output parameter. What parameter data type should I use? >> I tried adLongVarChar and adVarChar with the...
13
by: dbuchanan | last post by:
Hello, Here is the error message; ---------------------------- Exception Message: ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType requires the child key values (5) to exist in the...
2
by: tshad | last post by:
This has been driving me crazy. I have been trying to get the error handling working on my system and can get parts of it working and others won't work at all. I found that you can't access...
4
by: Mark Olbert | last post by:
I'm looking for help in getting the Transfer Sql Server Objects task to work. The goal is to transfer the tables, views, sprocs, udfs from a SqlServer 2000 database to a Sql Server 2005 database. ...
3
by: Nitinkcv | last post by:
Hi, While trying to run my app im getting the error Could not find a part of the path "c:\inetpub\wwwroot\Do not Delete\dbglobal.config". I checked and found that there is no Important_Do not...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
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...

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.