search

Last Reply on Feb 13, 2012 01:51 AM By nedash

Posted on Feb 11, 2012 04:30 AM

hi

i have 3 table in my database

Trade Table

 

T_code

Name

Keyword

1

Hotel

Hote

1

Hotel

Travel

1

Hotel

Room

2

Training

English

2

Training

Sport

 

 

hotel table

 

T_code

HotelName

HotelAddress

HotelTell

1

Milan

Germany

32436565

1

Paris

Franch

25435863

1

Italy

Veniz

3685686

training table

 

T_code

trainingName

Address

tell

2

English

Germany

53434646

2

Computer

Franch

25435863

2

Sport

Veniz

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?

 

 

 

 

 

 

 

 

 

 

 

Posted on Feb 12, 2012 10:33 PM

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

 


Posted on Feb 12, 2012 11:30 PM

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

 

I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html