Customize DataGrid View



Hi all,
I am using Visual Studio 2005 and Visual basic.

I've created a form with two ComboBoxes and a DataGrid
I binned the ComboBoxes to a table on my remote SQL2005 server

What I want to do is use the info from the two ComboBoxes
To create a SELECT query and display it on the DataGrid

For example:
If the user selected from cmb1 a "Username" and on cmb2 "failed
Execute a SELECT query

SELECT * from students where sname LIKE @cmb1 and status LIKE @cmb2

And show it on the DataGrid

Any Suggestions? (Would be greatly appreciated if someone can paste a
sample code)



Brendon Bezuidenhout

You could If you are building the string to run your select use
String.Format as so:

dim retVal as string = String.Format("SELECT * FROM Students WHERE sName
LIKE @{0} AND [Status] LIKE @{1}", Combo1Value.ToString,

BUT you might want to review doing this as it leaves the application open to
SQL injection attacks and could have someone running a DROP TABLE or DELETE
FROM statement on your DB tables.

HTH Brendon

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question