How to select certain table in my database
I'm currently using OleDB.
My problem is I can't select my table when searching it using textbox.
This is my code:
OleDbCommand inv = new OleDbCommand("Select [Part Number], [Part Name], [Ordered Quantity], [Arrived Quantity] From '"+textBox1.Text+"%'", PartsDB);
OleDbDataAdapter adapt = new OleDbDataAdapter(inv);
DataTable dt = new DataTable();
adapt.Fill(dt);
dataGridView2.DataSource = dt;
sql database select oledb
add a comment |
I'm currently using OleDB.
My problem is I can't select my table when searching it using textbox.
This is my code:
OleDbCommand inv = new OleDbCommand("Select [Part Number], [Part Name], [Ordered Quantity], [Arrived Quantity] From '"+textBox1.Text+"%'", PartsDB);
OleDbDataAdapter adapt = new OleDbDataAdapter(inv);
DataTable dt = new DataTable();
adapt.Fill(dt);
dataGridView2.DataSource = dt;
sql database select oledb
1
This is a SQL Injection Vulnerability, don't do this. Which database are you using? MYSQL, SQL SERVER, Oracle, etc?
– MatBailie
Nov 21 '18 at 8:03
Also: which programming language is that?
– a_horse_with_no_name
Nov 23 '18 at 9:07
add a comment |
I'm currently using OleDB.
My problem is I can't select my table when searching it using textbox.
This is my code:
OleDbCommand inv = new OleDbCommand("Select [Part Number], [Part Name], [Ordered Quantity], [Arrived Quantity] From '"+textBox1.Text+"%'", PartsDB);
OleDbDataAdapter adapt = new OleDbDataAdapter(inv);
DataTable dt = new DataTable();
adapt.Fill(dt);
dataGridView2.DataSource = dt;
sql database select oledb
I'm currently using OleDB.
My problem is I can't select my table when searching it using textbox.
This is my code:
OleDbCommand inv = new OleDbCommand("Select [Part Number], [Part Name], [Ordered Quantity], [Arrived Quantity] From '"+textBox1.Text+"%'", PartsDB);
OleDbDataAdapter adapt = new OleDbDataAdapter(inv);
DataTable dt = new DataTable();
adapt.Fill(dt);
dataGridView2.DataSource = dt;
sql database select oledb
sql database select oledb
edited Nov 23 '18 at 8:37
Ciarán
2,65211015
2,65211015
asked Nov 21 '18 at 4:42
Jed TurquezaJed Turqueza
1
1
1
This is a SQL Injection Vulnerability, don't do this. Which database are you using? MYSQL, SQL SERVER, Oracle, etc?
– MatBailie
Nov 21 '18 at 8:03
Also: which programming language is that?
– a_horse_with_no_name
Nov 23 '18 at 9:07
add a comment |
1
This is a SQL Injection Vulnerability, don't do this. Which database are you using? MYSQL, SQL SERVER, Oracle, etc?
– MatBailie
Nov 21 '18 at 8:03
Also: which programming language is that?
– a_horse_with_no_name
Nov 23 '18 at 9:07
1
1
This is a SQL Injection Vulnerability, don't do this. Which database are you using? MYSQL, SQL SERVER, Oracle, etc?
– MatBailie
Nov 21 '18 at 8:03
This is a SQL Injection Vulnerability, don't do this. Which database are you using? MYSQL, SQL SERVER, Oracle, etc?
– MatBailie
Nov 21 '18 at 8:03
Also: which programming language is that?
– a_horse_with_no_name
Nov 23 '18 at 9:07
Also: which programming language is that?
– a_horse_with_no_name
Nov 23 '18 at 9:07
add a comment |
2 Answers
2
active
oldest
votes
SQL Injection concerns aside this is not valid SQL. You are trying to make your table name 1) a string and 2) wild carded. This is not supported by any variant of SQL that I am aware of.
i.e.
Select column1, column2 From 'Tablename%'
is not valid SQL. You must say...
Select column1, column2 From Tablename
where Tablename exists as a table in your database
add a comment |
What is it that makes you have several distinct tables in your database that you should be able to do that same SELECT from ?
In principle, if you have that situation, then there must be some information element that distinguishes those tables from one another, and the intent of the relational model is for such tables to be combined into one, with the distinguishing element included as an additional attribute (/column).
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%2f53405383%2fhow-to-select-certain-table-in-my-database%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
SQL Injection concerns aside this is not valid SQL. You are trying to make your table name 1) a string and 2) wild carded. This is not supported by any variant of SQL that I am aware of.
i.e.
Select column1, column2 From 'Tablename%'
is not valid SQL. You must say...
Select column1, column2 From Tablename
where Tablename exists as a table in your database
add a comment |
SQL Injection concerns aside this is not valid SQL. You are trying to make your table name 1) a string and 2) wild carded. This is not supported by any variant of SQL that I am aware of.
i.e.
Select column1, column2 From 'Tablename%'
is not valid SQL. You must say...
Select column1, column2 From Tablename
where Tablename exists as a table in your database
add a comment |
SQL Injection concerns aside this is not valid SQL. You are trying to make your table name 1) a string and 2) wild carded. This is not supported by any variant of SQL that I am aware of.
i.e.
Select column1, column2 From 'Tablename%'
is not valid SQL. You must say...
Select column1, column2 From Tablename
where Tablename exists as a table in your database
SQL Injection concerns aside this is not valid SQL. You are trying to make your table name 1) a string and 2) wild carded. This is not supported by any variant of SQL that I am aware of.
i.e.
Select column1, column2 From 'Tablename%'
is not valid SQL. You must say...
Select column1, column2 From Tablename
where Tablename exists as a table in your database
edited Nov 22 '18 at 11:55
answered Nov 22 '18 at 9:55
CiaránCiarán
2,65211015
2,65211015
add a comment |
add a comment |
What is it that makes you have several distinct tables in your database that you should be able to do that same SELECT from ?
In principle, if you have that situation, then there must be some information element that distinguishes those tables from one another, and the intent of the relational model is for such tables to be combined into one, with the distinguishing element included as an additional attribute (/column).
add a comment |
What is it that makes you have several distinct tables in your database that you should be able to do that same SELECT from ?
In principle, if you have that situation, then there must be some information element that distinguishes those tables from one another, and the intent of the relational model is for such tables to be combined into one, with the distinguishing element included as an additional attribute (/column).
add a comment |
What is it that makes you have several distinct tables in your database that you should be able to do that same SELECT from ?
In principle, if you have that situation, then there must be some information element that distinguishes those tables from one another, and the intent of the relational model is for such tables to be combined into one, with the distinguishing element included as an additional attribute (/column).
What is it that makes you have several distinct tables in your database that you should be able to do that same SELECT from ?
In principle, if you have that situation, then there must be some information element that distinguishes those tables from one another, and the intent of the relational model is for such tables to be combined into one, with the distinguishing element included as an additional attribute (/column).
answered Nov 22 '18 at 14:28
Erwin SmoutErwin Smout
14.9k42148
14.9k42148
add a comment |
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%2f53405383%2fhow-to-select-certain-table-in-my-database%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
1
This is a SQL Injection Vulnerability, don't do this. Which database are you using? MYSQL, SQL SERVER, Oracle, etc?
– MatBailie
Nov 21 '18 at 8:03
Also: which programming language is that?
– a_horse_with_no_name
Nov 23 '18 at 9:07