SQL Select satement question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

This may be a bit of a newbie question with an obvious answer, but I've dug
around everywhere and can't find out how to do it. I'm creating a .net web
app and have a series of drop-down lists that are all tied to sql tables.
The select statement in each of the drop-downs is based on the selection in
the previous drop-down (think the same sort of functionality that you see at
large automotive sites where you pick the year, and then the make and finally
the model).

I know that I have to concatenate all of the select statements after the
first one, but I don't know how to grab the selected value. The page itself
is asp.NET but the code behind everything is vb.NET

Thanks in advance,
-Mike
 
Cor,

We're definitely getting closer - now when the page opens, it correctly runs
the Select satement based on the top value (in the table) of the previous
DropDownList. My problem is that I can't find any obvious property that will
allow me to 're-fire' the select statement in the desired drop-down when the
choice in the previous field changes.

The code that I'm using in the select statement is:
Me.SqlSelectCommand3.CommandText = "SELECT ProdName FROM Products WHERE
VendorName = ('" & DropDownList1.SelectedValue() & "')"

where 'VendorName' is selected in the previous drop-down list (MS, Symantec,
Veritas, etc.) Due to the way I put things in to the Vendor table, Microsoft
is at the top and hence is the value that's always used in the above SELECT
statement - I'm just trying to determine what the event is that I can put the
above CommandText in to have it fire whenever the Vendor choice is changed.

Thanks a lot for the help.
-Mike
 
Mike,

First of all try those parameters I showed you. (One of the first thing you
will hear forever when you show the code as you use in this newsgroup)..

It is very easy to use basicly nothing more than with one
sqlSelectCommand3.parameters.add(@vendorname)

And than in the SelectedIndedChange event
sqlSelectCommand3.parameters
_("@vendorname").value=DropDownList1.SelectedValue.toString
And than fill of course the dataset with that or whatever method you use.

Then did you set the autopostback of the dropdownlist to true and than it is
just the SelectedIndexChanged event where you are looking for,

I hope this helps so far?

Cor
 
Cor,

I have made some progress today. With your help I now understand how
parameters work and everything works perfectly - if I don't mind having a
couple of buttons on the page that users click to fire off the events - but
that's for a posting under a separate topic.

Thanks a lot.
-Mike
 
Back
Top