hi
i have 3 table in my database
Trade Table
T_code
Name
Keyword
1
Hotel
Hote
Travel
Room
2
Training
English
Sport
hotel table
HotelName
HotelAddress
HotelTell
Milan
Germany
32436565
Paris
Franch
25435863
Italy
Veniz
3685686
training table
trainingName
Address
tell
53434646
Computer
254
i want when user write keyword that exist in trade table it connect to table that is in keyword rows
EX: user write room in TB and click search button it will connect to Hotel table and show hotel table columns
i dont know how i can make relation between trade-hotel-training Tables?
you need to create following two procedur
CREATE PROCEDURE SP_GetTableCode @Key varchar(50)ASBEGIN SET NOCOUNT ON; select T_Code from tradeTable where Keword= @Key END
CREATE PROCEDURE SP_GetDetails @T_Code intASBEGIN SET NOCOUNT ON; if @T_Code = 1 begin select * from HotelTable end else if @T_Code = 2 begin select * from tranigtable endEND
I am novice in sql i cant Understand what are these code?
1-where should i put these code in my website page in my
protected void serach_Click(object sender, EventArgs e)
{
}
2-are there other code instead of these procedur?
This is the query you need
declare @tcode int select @tcode = t_code from Trade table if tcode = 1 begin select hotelname from hotel end if tcode = 2 begin select trainingName from training end
Create following sp in Sql Database
For refe : http://www.aspsnippets.com/Articles/Using-Stored-Procedures-in-SQL-Server-Database.aspx
SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE PROCEDURE GetDetails @KeyWord varchar(50)ASBEGIN SET NOCOUNT ON;Declare @TCode int Select @TCode = T_code from Trade where KeyWord = @KeyWordIf @TCode =1 Begin Select * from HotelEnd If @ TCode =2BeginSelect * from trainingEnd END
Call this SP in your Search_Click Event
For Refe : http://www.aspsnippets.com/Articles/Calling-Select-SQL-Server-Stored-Procedures-using-ADO.Net.aspx
tanx alot
i do it
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.