vhFlores


my FirstDataBaseDataset came with a sql that selected everything
(like SELECT * FROM ADDRESSES) (it actually listed each field name)


so when i can get all 3 records and go thru them one by one,
by pressing the 'next' arrow

What i want to do, is set up a combo box, so you can select a City,
and then when i select 'New York', i want to refresh the records that
i can see- i want my FirstDataBaseDataset to run again, and this time,
i want to select only those where the city is New York

Is that possible
I could not even modify the sql for the dataset,

i want to do something like this:

select * from addresses
where City IS NULL or CITY = ComboBox1.selectedItem()


but it doesnt like this: 'ComboBox1.SelectedItem()'

Any ideas

do i put a colon :ComboBox1.SelectedItem()

do i put a @

what do i use



Re: Visual Basic Express Edition how do i use 'ComboBox1.SelectedItem()' from inside a SQL Statement??

spotty

You simple use the value to either insert into a SQL Statement string - which is not good because of potential for SQL Injection.

Code Snippet

Dim s as string = "SELECT * from addresses WHERE city is null or city = '" & combobox1.selectedItem() & "'"

Or

use the value as a parameter on a SQL Command Object parameter collection.





Re: Visual Basic Express Edition how do i use 'ComboBox1.SelectedItem()' from inside a SQL Statement??

vhFlores

thank you for your informative and elegant reply!

sql injection, huh

like someone could make the name of the city

'a' or 't'='t'

and that could be bad, very bad.





Re: Visual Basic Express Edition how do i use 'ComboBox1.SelectedItem()' from inside a SQL Statement??

vhFlores

ok some time has gone by and i am looking everywhere and i really dont know

i guess i just dont know enough, huh


Like maybe i want to run and i dont know how to walk....(not even crawl )

i am in vb
looking at the properties of "FirstDatabaseDataSet.xsd*"

One of the properties is called 'Command text' and it currently has this command:
<<<
SELECT FirstName, LastName, StreetAddress, City, Phone
FROM Addresses
>>>

how do i change that to the string you gave me


remember 's'

(Dim s as string = "SELECT * from addresses WHERE city is null or city = '" & combobox1.selectedItem() & "'")


if i put 's' in the command text, it doesnt like it!


I think there is something i have to run manually

Is there a particular path you recommend like a book, a class or something for guys like me