• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 294
  • Last Modified:

SQL fieldname equals data from a textbox in a select statement

Hello,

Well my question is :

How do I create a SQL Select statement that uses the Text value from a VB.NET textbox ?

Select *  From textbox2.text     or Select textbox1.text From textbox2.text

What is the correct syntax if I am using a Textbox or Combobox ?

Thanks!!
0
abennett10
Asked:
abennett10
1 Solution
 
Bob LearnedCommented:
"Select * From '" & textbox2.text & "'"

"Select " & textbox1.text & " From " & textbox2.text

Bob
0
 
YZlatCommented:
select * from Table1 where field1 ='" & TextBox1.Text & "'" (if value is a string)

select * from Table1 where field1 =" & TextBox1.Text  (if value is numeric)


select * from Table1 where field1 =" & ComboBox1.SelectedValue

or

select * from Table1 where field1 ='" & ComboBox1.SelectedText & "'"
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now