.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
MarieAdela
Imran Ghani
Post New Web Links

RaiseError

Posted By:      Posted Date: October 19, 2010    Points: 0   Category :Sql Server
 

I am trying to implement an error that will only be raised if certain conditions exist.  I've implemented the first one below but it still raises the error if prc_typ_id is in the parantheses ()

 

ELSE

IF EXISTS (SELECT * FROM T_PRC_WRK WHERE PRC_TYP_ID NOT IN (30,37,38, 39,68)) 
BEGIN
	RAISERROR('error msg here.',16,1)
END

Can you recommend an alternative?  is the code below essentially saying the same thing?

 

ELSE

IF NOT EXISTS (SELECT * FROM T_PRC_WRK WHERE PRC_TYP_ID IN (30,37,38, 39,68)) 
BEGIN
	RAISERROR('error msg here',16,1)
END

KDW


View Complete Post


More Related Resource Links

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: RAISEERROR

  

I'm getting this error:


Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: You cannot add to the repair list until the barcode is added to Inventory first.

 Now the 'You cannot add to the repair list until the barcode is added to Inventory first.' is my own message being returned from

sql server.

 

I have a datagrid with a new button on it. When the user clicks on the button I insert a blank row in the grid. They then go to edit the record to put info in the grid.

Since the system is a barcode driven system, I check the barcode they entered to make sure it's in the system. If not I throw the message from sql server using the RAISEERROR event.

Here is the partial sql code:

	if not exists(select * from dbo.tblIndentification 
				where Identification_Barcode = @barcode) 
	begin
		RAISERROR(50020,11,1)  with NOWAIT
		return -1
		
	end

 

Here  is the c# code:

                else if (e.CommandName.Equals("Update"))
                {
                    //for use in conjuction when the user inserts a new row
                    if  (txtCurrentRowBeingEdited.Text=="")
                    {
                       
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend