Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
7
Reply
How to search db value with 'or' condition sql server
Bineesh VP
Sep 16 2017 4:53 AM
238
Reply
Hi Sir,
I am in a project in which I need to implement search criteria using OR condition.
means, I need to search different column values based upon one sql parameter.
Kindly tell me the below query to replace 'AND' condition with 'OR'
isnull(cast(tblCustomer.strMobile as nvarchar (20)),'') LIKE '%'+@asMobile+'%'
and
isnull(cast(tblCustomer.strPhoneOff as nvarchar (20)),'') LIKE '%'+@asMobile+'%' and
isnull(cast(tblCustomer.strPhoneOff1 as nvarchar (20)),'') LIKE '%'+@asMobile+'%' and
isnull(cast(tblCustomer.strPhoneRes as nvarchar (20)),'') LIKE '%'+@asMobile+'%'
for c# code , I given like this:-
cmd.Parameters.Add("@asstrMobile", SqlDbType.NVarChar).Value = tbxOfficeResMobile.Text.Trim();
cmd.Parameters.Add("@asPhoneOff", SqlDbType.NVarChar).Value = tbxOfficeResMobile.Text.Trim();
cmd.Parameters.Add("@asPhoneOff1", SqlDbType.NVarChar).Value = tbxOfficeResMobile.Text.Trim();
cmd.Parameters.Add("@asPhoneRes", SqlDbType.NVarChar).Value = tbxOfficeResMobile.Text.Trim();
This code is not working because of all parameter taking same value. I think I need to change the SQL
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
7
)
Next Recommended Forum
how do i cast object from data reader to boolean value ?
What is the best way to increment a transaction number