Wildcard in query for ASP.NET GridView
Posted
by cinu
on Stack Overflow
See other posts from Stack Overflow
or by cinu
Published on 2009-03-11T02:40:24Z
Indexed on
2010/05/23
7:10 UTC
Read the original article
Hit count: 186
I am using GridView in ASP.NET 2.0. I am want to show the details from 3 tables (SQL2005) in the GridView per my search crieteria (Name of Visitor,Passport Number,Name of Company). It is working, but I want to use a wildcard for searching by first letter of "Name of Visitor". I have my code in the QueryBuilder in GridView (using Configure Datasource). The query is as follows:
SELECT FormMaster.NameofCompany, VisitorMaster.NameofVisitor,
VisitorMaster.PassportNumber, FormMaster.FormID,
VisitorMaster.VisitorID FROM VisitorMaster INNER JOIN VisitorDetails ON
VisitorMaster.VisitorID = VisitorDetails.VisitorID INNER JOIN FormMaster ON
VisitorDetails.FormID = FormMaster.FormID WHERE (FormMaster.FormStatusID = 1) AND
(VisitorMaster.PassportNumber = @PassportNumber ) OR
(VisitorMaster.NameofVisitor = @NameofVisitor) OR
(FormMaster.NameofCompany = @NameofCompany )
© Stack Overflow or respective owner