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

Re: SQL Select satement question by Cor

Cor
Sun Nov 14 03:11:55 CST 2004

Mike,

Just take the selecteditem from your dropddown and use that in your OleDb or
SQLparameter in by instance a select clause like this.

Select mynextfield from my table Where SelectedFirstComboBoxField =
@myparameterfield

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatasqlclientsqlparameterclasstopic.asp

Use this to Fill a dataset and use that one for your next combobox.

I hope this helps?

Cor

"Mike_NH" <MikeNH@discussions.microsoft.com>


> 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



Re: SQL Select satement question by MikeNH

MikeNH
Mon Nov 15 10:44:02 CST 2004

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
"Cor Ligthert" wrote:

> Mike,
>
> Just take the selecteditem from your dropddown and use that in your OleDb or
> SQLparameter in by instance a select clause like this.
>
> Select mynextfield from my table Where SelectedFirstComboBoxField =
> @myparameterfield
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatasqlclientsqlparameterclasstopic.asp
>
> Use this to Fill a dataset and use that one for your next combobox.
>
> I hope this helps?
>
> Cor
>
> "Mike_NH" <MikeNH@discussions.microsoft.com>
>
>
> > 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
>
>
>

Re: SQL Select satement question by Cor

Cor
Tue Nov 16 06:33:12 CST 2004

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

"Mike_NH" <MikeNH@discussions.microsoft.com> schreef in bericht
news:BC8F99F8-A161-4988-8197-D62E424A0335@microsoft.com...
> 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
> "Cor Ligthert" wrote:
>
>> Mike,
>>
>> Just take the selecteditem from your dropddown and use that in your OleDb
>> or
>> SQLparameter in by instance a select clause like this.
>>
>> Select mynextfield from my table Where SelectedFirstComboBoxField =
>> @myparameterfield
>>
>> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatasqlclientsqlparameterclasstopic.asp
>>
>> Use this to Fill a dataset and use that one for your next combobox.
>>
>> I hope this helps?
>>
>> Cor
>>
>> "Mike_NH" <MikeNH@discussions.microsoft.com>
>>
>>
>> > 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
>>
>>
>>



Re: SQL Select satement question by MikeNH

MikeNH
Tue Nov 16 13:36:02 CST 2004

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

"Cor Ligthert" wrote:

> 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
>
> "Mike_NH" <MikeNH@discussions.microsoft.com> schreef in bericht
> news:BC8F99F8-A161-4988-8197-D62E424A0335@microsoft.com...
> > 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
> > "Cor Ligthert" wrote:
> >
> >> Mike,
> >>
> >> Just take the selecteditem from your dropddown and use that in your OleDb
> >> or
> >> SQLparameter in by instance a select clause like this.
> >>
> >> Select mynextfield from my table Where SelectedFirstComboBoxField =
> >> @myparameterfield
> >>
> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatasqlclientsqlparameterclasstopic.asp
> >>
> >> Use this to Fill a dataset and use that one for your next combobox.
> >>
> >> I hope this helps?
> >>
> >> Cor
> >>
> >> "Mike_NH" <MikeNH@discussions.microsoft.com>
> >>
> >>
> >> > 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
> >>
> >>
> >>
>
>
>