473,779 Members | 2,015 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stored Procedure should not enter same name with diff id...HELP

16 New Member
Hi frdz,

I have created the form for entering the company details with its general information in asp.net C# 2005.

I want to put the validation that the user cannot enter the same name of company's twice with the different id's.

I have created the stored procedure for the insert and update :

The following is the insert stored procedure created in the SQL SERVER 2005.
Expand|Select|Wrap|Line Numbers
  1.  
  2. if exists (Select companyname from companymaster where companyname =@companyname)
  3.         Print 'CompanyName already exists'
  4.       IF NOT EXISTS( SELECT companyname FROM companymaster WHERE companyname <> @companyname and companyid <> @companyid)
  5.     BEGIN
  6.         INSERT INTO companymaster
  7.                           (companyname, address1,address2,abbrecomp)
  8.         VALUES     (@companyname,@address1,@address2,@abbrecomp)
  9.         SELECT @companyid = SCOPE_IDENTITY()
  10.  
  11.  


The stored procedure is running but inspite of checking that companyname is not equal to companyname it allows me to add the companyname with the same name again creating the identity of the companyid.

I want to execute this stored procedure for my asp.net C# 2005.

Can i use trigger for the insert of the companyname with same name existing check ??

If yes,then can anyone tell me how to write the trigger for the above insert tabel of the insert query.
Or else just tell me what should be modified for the stored procedure code...

Thanxs in adv.
May 4 '07 #1
0 864

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

Similar topics

5
7294
by: Warren Wright | last post by:
Hi group, I have a select statement that if run against a 1 million record database directly in query analyzer takes less than 1 second. However, if I execute the select statement in a stored procedure instead, calling the stored proc from query analyzer, then it takes 12-17 seconds. Here is what I execute in Query Analyzer when bypassing the stored procedure:
6
2320
by: Wim van Rosmalen | last post by:
I've upgraded MS-Access 2002 to a MS-Access Project (adp), so now I have to deal with more sophisticated queries (may I call them so?) like stored procedures. I have a form with a combobox for selections and a textbox to enter a certain value. Let us say I call the combobox @select and the textbox @find. The combobox always shows the first of the items to select. Now I want to return a message if nothing is found, or if nothing has been...
2
2333
by: jaYPee | last post by:
I have an existing query from MS Access that I want to convert it to SQL Server Stored Proc. My problem is on how to convert the WHERE clause. This is the query from MS Access: SELECT SchYrSemCourseJoin.SchYrSemCourseID, Students.IDNo, & ", " & & " " & AS Name, Program.ProgramTitle, Program.ProgramDesc, SchYrSem.SchYr, SchYrSem.Sem, SchYrSem.Year, SchYrSem.Section AS Section1,
2
11709
by: Josh Strickland | last post by:
I am attempting to create an Access database which uses forms to enter data. The issue I am having is returning the query results from the Stored Procedure back in to the Access Form. tCetecM1CUST (SQL Table that contains the Customer Information) tAccountingDetail (SQL Table that contains the information in the form) frmAccountingEntry (Access form used to enter data) spGetCustomerInformation (Stored Procedure which returns data using...
9
8989
by: jyothi1105 | last post by:
Hi all, Here is some information which could help people who want to create stored procedures and execute them in their program. You can create stored procedures in two ways: Through front end or writing procedure from backend SQLServer. Back End First we'll cover how to write a stored procedure in back end. The following example is how to create a store procedure for MSSql Server:
0
1724
by: Riaaaa | last post by:
Hello members, This is the SQL SERVER 2005 stored procedure. It contains the data from the two diff tables. (1)Customer : Here clpid and cardid are composite primary keys with the identity field.It has storeid as foreign key. The cardid is to be autogenerated everytime as the new customer is inserted. I have to put the validations for the
5
1783
by: bbawa1 | last post by:
I have the following stroed procedue. But whebnnI execute it it gives me following errors. Could you please tell me what is wrong Msg 156, Level 15, State 1, Procedure usp_DateDiff, Line 43 Incorrect syntax near the keyword 'SELECT'. Msg 156, Level 15, State 1, Procedure usp_DateDiff, Line 47 Incorrect syntax near the keyword 'select'. Msg 156, Level 15, State 1, Procedure usp_DateDiff, Line 52 Incorrect syntax near the keyword...
0
3192
by: SOI_0152 | last post by:
Hi all! Happy New Year 2008. Il hope it will bring you love and happyness I'm new on this forum. I wrote a stored procedure on mainframe using DB2 7.1.1 and IBM language c. Everything works fine. Now we decided to move from mainframe IMS-DB2 to Windows 2003 server-DB2 UDB for LUW 9.5.
20
6305
by: billmaclean1 | last post by:
I need to write a stored procedure that selects from a table and returns the result set. I don't always know the TableSchema that I need to use when qualifying the table at run-time Example: The correct table could either be dbo.MyTable or zzz.MyTable. I want the user to enter the name of the schema as a parameter of the procedure at run-time.
0
10306
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
10138
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
8961
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
7485
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
5373
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
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
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
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.