Search Multiple Database Columns with a Single Textbox Using dataGridView
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I am trying to use a single textbox to search multiple
columns in a database. The following code works for one
single column.
private void tboxSearchRID_TextChanged(object sender, EventArgs e)
{
DataView dv = dt.DefaultView;
dv.RowFilter = "RID1 LIKE '%" + tboxSearchRID.Text + "%'" ;
}
This code works fine with just the single Database column RID1.
Is there a way that I can include RID2, RID3, RID4 into the same
search?
Here is a snapshot of my Search Form
My Search Form
c#
add a comment |
I am trying to use a single textbox to search multiple
columns in a database. The following code works for one
single column.
private void tboxSearchRID_TextChanged(object sender, EventArgs e)
{
DataView dv = dt.DefaultView;
dv.RowFilter = "RID1 LIKE '%" + tboxSearchRID.Text + "%'" ;
}
This code works fine with just the single Database column RID1.
Is there a way that I can include RID2, RID3, RID4 into the same
search?
Here is a snapshot of my Search Form
My Search Form
c#
add a comment |
I am trying to use a single textbox to search multiple
columns in a database. The following code works for one
single column.
private void tboxSearchRID_TextChanged(object sender, EventArgs e)
{
DataView dv = dt.DefaultView;
dv.RowFilter = "RID1 LIKE '%" + tboxSearchRID.Text + "%'" ;
}
This code works fine with just the single Database column RID1.
Is there a way that I can include RID2, RID3, RID4 into the same
search?
Here is a snapshot of my Search Form
My Search Form
c#
I am trying to use a single textbox to search multiple
columns in a database. The following code works for one
single column.
private void tboxSearchRID_TextChanged(object sender, EventArgs e)
{
DataView dv = dt.DefaultView;
dv.RowFilter = "RID1 LIKE '%" + tboxSearchRID.Text + "%'" ;
}
This code works fine with just the single Database column RID1.
Is there a way that I can include RID2, RID3, RID4 into the same
search?
Here is a snapshot of my Search Form
My Search Form
c#
c#
asked Nov 25 '18 at 0:07
Jim NeelJim Neel
82
82
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
We are talking about an ADO.NET DataView right?
You can use a filter that applies to multiply columns OR
in the SQL:
dv.RowFilter = string.Format(
"RID1 LIKE '%{0}%' OR RID2 LIKE '%{0}%' OR RID3 LIKE '%{0}%' OR RID4 LIKE '%{0}%'", tboxSearchRID.Text
);
And a Home run for you, my friend. How fortunate to get the perfect answer on the first try. I'm only a hobby programmer with (believe it or not) about 2 - 3 weeks experience and absolutely no training. So, my questions may be simple, but a real PITA to solve on my own. Thank you so much
– Jim Neel
Nov 25 '18 at 2:05
@JimNeel you are welcomed. Keep the spirit!
– wp78de
Nov 25 '18 at 2:06
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53463531%2fsearch-multiple-database-columns-with-a-single-textbox-using-datagridview%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
We are talking about an ADO.NET DataView right?
You can use a filter that applies to multiply columns OR
in the SQL:
dv.RowFilter = string.Format(
"RID1 LIKE '%{0}%' OR RID2 LIKE '%{0}%' OR RID3 LIKE '%{0}%' OR RID4 LIKE '%{0}%'", tboxSearchRID.Text
);
And a Home run for you, my friend. How fortunate to get the perfect answer on the first try. I'm only a hobby programmer with (believe it or not) about 2 - 3 weeks experience and absolutely no training. So, my questions may be simple, but a real PITA to solve on my own. Thank you so much
– Jim Neel
Nov 25 '18 at 2:05
@JimNeel you are welcomed. Keep the spirit!
– wp78de
Nov 25 '18 at 2:06
add a comment |
We are talking about an ADO.NET DataView right?
You can use a filter that applies to multiply columns OR
in the SQL:
dv.RowFilter = string.Format(
"RID1 LIKE '%{0}%' OR RID2 LIKE '%{0}%' OR RID3 LIKE '%{0}%' OR RID4 LIKE '%{0}%'", tboxSearchRID.Text
);
And a Home run for you, my friend. How fortunate to get the perfect answer on the first try. I'm only a hobby programmer with (believe it or not) about 2 - 3 weeks experience and absolutely no training. So, my questions may be simple, but a real PITA to solve on my own. Thank you so much
– Jim Neel
Nov 25 '18 at 2:05
@JimNeel you are welcomed. Keep the spirit!
– wp78de
Nov 25 '18 at 2:06
add a comment |
We are talking about an ADO.NET DataView right?
You can use a filter that applies to multiply columns OR
in the SQL:
dv.RowFilter = string.Format(
"RID1 LIKE '%{0}%' OR RID2 LIKE '%{0}%' OR RID3 LIKE '%{0}%' OR RID4 LIKE '%{0}%'", tboxSearchRID.Text
);
We are talking about an ADO.NET DataView right?
You can use a filter that applies to multiply columns OR
in the SQL:
dv.RowFilter = string.Format(
"RID1 LIKE '%{0}%' OR RID2 LIKE '%{0}%' OR RID3 LIKE '%{0}%' OR RID4 LIKE '%{0}%'", tboxSearchRID.Text
);
answered Nov 25 '18 at 1:19
wp78dewp78de
10.5k62044
10.5k62044
And a Home run for you, my friend. How fortunate to get the perfect answer on the first try. I'm only a hobby programmer with (believe it or not) about 2 - 3 weeks experience and absolutely no training. So, my questions may be simple, but a real PITA to solve on my own. Thank you so much
– Jim Neel
Nov 25 '18 at 2:05
@JimNeel you are welcomed. Keep the spirit!
– wp78de
Nov 25 '18 at 2:06
add a comment |
And a Home run for you, my friend. How fortunate to get the perfect answer on the first try. I'm only a hobby programmer with (believe it or not) about 2 - 3 weeks experience and absolutely no training. So, my questions may be simple, but a real PITA to solve on my own. Thank you so much
– Jim Neel
Nov 25 '18 at 2:05
@JimNeel you are welcomed. Keep the spirit!
– wp78de
Nov 25 '18 at 2:06
And a Home run for you, my friend. How fortunate to get the perfect answer on the first try. I'm only a hobby programmer with (believe it or not) about 2 - 3 weeks experience and absolutely no training. So, my questions may be simple, but a real PITA to solve on my own. Thank you so much
– Jim Neel
Nov 25 '18 at 2:05
And a Home run for you, my friend. How fortunate to get the perfect answer on the first try. I'm only a hobby programmer with (believe it or not) about 2 - 3 weeks experience and absolutely no training. So, my questions may be simple, but a real PITA to solve on my own. Thank you so much
– Jim Neel
Nov 25 '18 at 2:05
@JimNeel you are welcomed. Keep the spirit!
– wp78de
Nov 25 '18 at 2:06
@JimNeel you are welcomed. Keep the spirit!
– wp78de
Nov 25 '18 at 2:06
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53463531%2fsearch-multiple-database-columns-with-a-single-textbox-using-datagridview%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown