Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi friends...i have a 4 fileds in my my page and database name is skills having 4 columns.they are skillid,skillname(textbox1),parentskill(dropdownlist) and finally filtertext(textbox2).
note:At first our database table is empty
here skillid is kept as autogenerate id number while designing the table.so skillid is not visible to user...
so..user will enter the details like ".NET" in textbox1 and as we know that .NET is the parentskill rt so user wont select any item in dropdownlist and he entered the value in filter text like ".NET" only.
Now in skills table the first row is inserted like this "1 .NET NULL .NET",Now after the page is postback .NET shoulbe be enter in to dropdownlist where...
now user will enter the details like this.."2 c# 1 csharp" where here "1" represents the
parent .NET (skillid number).... like this the rows are inserted..

skillid skillname parentskill filtertext
1 .NET NULL .NET
2 C# 1 CSHARP
3 ASP.NET 1 .NET
4 J2EE NULL J2EE
5 JAVA 4 JAVA

as above i completed the task but im anot able to avoid the entry of duplicate values in to my dropdownlist...plz help me the query frnds
Posted
Updated 30-Mar-15 0:56am
v3

The easiest way would be to do the duplicacy check in the stored procedure or query for inserting the record.

For example:
SQL
IF(NOT EXISTS(SELECT 1 FROM Skills WHERE skillname=@SkillName AND parentskill=@ParentSkill))
BEGIN
   //insert logic
END
ELSE
BEGIN
   //show duplicate exist msg
   SELECT 'Duplicate exists'
END

Now you can check if the query/stored proc returns anything then it has failed inserting and need to show the duplicacy message and if it succeeds, it means it will return nothing.

Hope, it helps :)
 
Share this answer
 
v2
Comments
NagaNimesh 11474558 31-Mar-15 0:00am    
tanq my dears for ur suggestion
use a primary key to avoid this and bind the dropdown with dropdown Id..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900