tough question for expert 
Author Message
 tough question for expert

(Note: question applies to vb.net, web form and sql)

I have two dropdown controls and one sql table with column 1 & 2. I
would like dropdown2 selection to be based on the selected item in
dropdown1.

For example, if dropdown1 selection is "oee" then I would like
dropdown2 to only show selection for items in the table column 2 where
column 1 has "oee" listed.

So what I am having trouble with is the connection string where I only
want to return items where equal to dropdown1 value...see my
connection string here:

Dim sql As String = "SELECT distinct column2 FROM MyTable Where
column1 =  webform.dropdown1"

I think i am hung up here where I am using the actual value in
dropdown1 on webform in my sql connection string...

Please advise.



Tue, 13 Mar 2012 21:31:41 GMT  
 tough question for expert


Quote:
> (Note: question applies to vb.net, web form and sql)

This is a VB6 and earlier group(VB Classic). VB.Net and all dotnet groups
have either "dotnet" or "vsnet" in the group name. Please use the following
group instead:




Tue, 13 Mar 2012 21:52:05 GMT  
 tough question for expert
Hi Jonny,

Well, assuming your combobox (dropdown1) is just displaying the raw values
of column1, it would be as simple as:

Dim sql As String = "SELECT distinct column2 FROM MyTable Where
column1 =  '" + webform.dropdown1.Text + "'"

Note that I've assumed you're using string values, so I've enclosed it in
single quotes ( ' ).

A slightly safer solution would be:

Dim sql As String = String.Format("SELECT distinct column2 FROM MyTable
Where
column1 =  '{0}'", webform.dropdown1.Text.Replace("'", "''"))

Which handles any single quotes inside the value itself to prevent malformed
SQL strings.

HTH,
Alex


Quote:
> (Note: question applies to vb.net, web form and sql)

> I have two dropdown controls and one sql table with column 1 & 2. I
> would like dropdown2 selection to be based on the selected item in
> dropdown1.

> For example, if dropdown1 selection is "oee" then I would like
> dropdown2 to only show selection for items in the table column 2 where
> column 1 has "oee" listed.

> So what I am having trouble with is the connection string where I only
> want to return items where equal to dropdown1 value...see my
> connection string here:

> Dim sql As String = "SELECT distinct column2 FROM MyTable Where
> column1 =  webform.dropdown1"

> I think i am hung up here where I am using the actual value in
> dropdown1 on webform in my sql connection string...

> Please advise.



Wed, 14 Mar 2012 01:32:43 GMT  
 tough question for expert
The OP posted his Q in the dotnet group at 15:27, so what is the point of
your reply in this group at 19:42??
Don't you "dotnet wizards" visit the dotnet groups?

/Henning



Quote:
> Hi Jonny,

> Well, assuming your combobox (dropdown1) is just displaying the raw values
> of column1, it would be as simple as:

> Dim sql As String = "SELECT distinct column2 FROM MyTable Where
> column1 =  '" + webform.dropdown1.Text + "'"

> Note that I've assumed you're using string values, so I've enclosed it in
> single quotes ( ' ).

> A slightly safer solution would be:

> Dim sql As String = String.Format("SELECT distinct column2 FROM MyTable
> Where
> column1 =  '{0}'", webform.dropdown1.Text.Replace("'", "''"))

> Which handles any single quotes inside the value itself to prevent
> malformed SQL strings.

> HTH,
> Alex



>> (Note: question applies to vb.net, web form and sql)

>> I have two dropdown controls and one sql table with column 1 & 2. I
>> would like dropdown2 selection to be based on the selected item in
>> dropdown1.

>> For example, if dropdown1 selection is "oee" then I would like
>> dropdown2 to only show selection for items in the table column 2 where
>> column 1 has "oee" listed.

>> So what I am having trouble with is the connection string where I only
>> want to return items where equal to dropdown1 value...see my
>> connection string here:

>> Dim sql As String = "SELECT distinct column2 FROM MyTable Where
>> column1 =  webform.dropdown1"

>> I think i am hung up here where I am using the actual value in
>> dropdown1 on webform in my sql connection string...

>> Please advise.



Wed, 14 Mar 2012 03:37:16 GMT  
 tough question for expert

over to alt.two.dollar.{*filter*}s and told his strung out crack head mom to put
his muzzle back on, for all the good it will do.

--
2025
If you do not believe in time travel,
your beliefs are about to be tempered.

http://www.*-*-*.com/

| The OP posted his Q in the dotnet group at 15:27, so what is the point of
| your reply in this group at 19:42??
| Don't you "dotnet wizards" visit the dotnet groups?
|
| /Henning
|


| > Hi Jonny,
| >
| > Well, assuming your combobox (dropdown1) is just displaying the raw
values
| > of column1, it would be as simple as:
| >
| > Dim sql As String = "SELECT distinct column2 FROM MyTable Where
| > column1 =  '" + webform.dropdown1.Text + "'"
| >
| > Note that I've assumed you're using string values, so I've enclosed it
in
| > single quotes ( ' ).
| >
| > A slightly safer solution would be:
| >
| > Dim sql As String = String.Format("SELECT distinct column2 FROM MyTable
| > Where
| > column1 =  '{0}'", webform.dropdown1.Text.Replace("'", "''"))
| >
| > Which handles any single quotes inside the value itself to prevent
| > malformed SQL strings.
| >
| > HTH,
| > Alex
| >
| >
| >

| >

| >> (Note: question applies to vb.net, web form and sql)
| >>
| >> I have two dropdown controls and one sql table with column 1 & 2. I
| >> would like dropdown2 selection to be based on the selected item in
| >> dropdown1.
| >>
| >> For example, if dropdown1 selection is "oee" then I would like
| >> dropdown2 to only show selection for items in the table column 2 where
| >> column 1 has "oee" listed.
| >>
| >> So what I am having trouble with is the connection string where I only
| >> want to return items where equal to dropdown1 value...see my
| >> connection string here:
| >>
| >> Dim sql As String = "SELECT distinct column2 FROM MyTable Where
| >> column1 =  webform.dropdown1"
| >>
| >> I think i am hung up here where I am using the actual value in
| >> dropdown1 on webform in my sql connection string...
| >>
| >> Please advise.
| >
| >
|
|



Wed, 14 Mar 2012 04:52:47 GMT  
 tough question for expert

Look, I'm far from the raving .NET haters in here, but I agree that posting
answers to off-topic posts is a bad thing, and you really are coming off
looking like a troll by doing it. Don't answer .NET questions here. Redirect
the poster.



Wed, 14 Mar 2012 05:18:48 GMT  
 tough question for expert



Quote:


> Look, I'm far from the raving .NET haters in here, but I agree that
> posting answers to off-topic posts is a bad thing, and you really are
> coming off looking like a troll by doing it. Don't answer .NET questions
> here. Redirect the poster.

I don't think there are many dotnet haters here, there is no reason. It's
all about stubborn people who have not got the fact that Microsoft has
started dedicated groups for theese questions.

/Henning



Wed, 14 Mar 2012 06:31:18 GMT  
 tough question for expert


Quote:
> Hi Jonny,

> Well, assuming your combobox (dropdown1) is just displaying the raw values
> of column1, it would be as simple as:

> Dim sql As String = "SELECT distinct column2 FROM MyTable Where
> column1 =  '" + webform.dropdown1.Text + "'"

Regardless of what version of VB someone is using they should never
concatenate SQL query strings taking direct user input like the above,
instead they should either parse the input for any SQL escape characters of
use the parameters collection of the command. I'd favor the later approach
of using the parameters collection: as that is slightly different in ado.net
compared to dao or ado in VB6, probably best to ask this question about
using the parameters collection in the dotnet newsgroups such as :
microsoft.public.dotnet.languages.vb


Wed, 14 Mar 2012 08:08:32 GMT  
 tough question for expert


Quote:

> I don't think there are many dotnet haters here, there is no reason. It's
> all about stubborn people who have not got the fact that Microsoft has
> started dedicated groups for theese questions.

As usual, it seems there's more noise from those arguing about the help
being provided than the answer itself causes.


Wed, 14 Mar 2012 08:04:34 GMT  
 tough question for expert



Quote:
> As usual, it seems there's more noise from those arguing about
> the help being provided than the answer itself causes.

As usual another "heat-up-attempt" from Troll McCarthy.

Go away Alex.

Olaf



Wed, 14 Mar 2012 08:32:17 GMT  
 tough question for expert


Quote:



>> As usual, it seems there's more noise from those arguing about
>> the help being provided than the answer itself causes.
> As usual another "heat-up-attempt" from Troll McCarthy.

> Go away Alex.

> Olaf

QED.


Wed, 14 Mar 2012 10:03:39 GMT  
 tough question for expert
This coming from the biggest instigator.  Go away Bill/Scott/Alex, whatever
you are calling yourself these days.

--
2025
If you do not believe in time travel,
your beliefs are about to be tempered.

http://www.facebook.com/group.php?gid=43606237254

|
|

| >>
| > I don't think there are many dotnet haters here, there is no reason.
It's
| > all about stubborn people who have not got the fact that Microsoft has
| > started dedicated groups for theese questions.
| >
|
| As usual, it seems there's more noise from those arguing about the help
| being provided than the answer itself causes.
|



Wed, 14 Mar 2012 10:26:49 GMT  
 tough question for expert
|
| QED.

GFY AH



Wed, 14 Mar 2012 10:28:14 GMT  
 tough question for expert



Quote:



>> I don't think there are many dotnet haters here, there is no reason. It's
>> all about stubborn people who have not got the fact that Microsoft has
>> started dedicated groups for theese questions.

> As usual, it seems there's more noise from those arguing about the help
> being provided than the answer itself causes.

Well, some people might call it help.
Alex posted the answere here, 4 hours after the OP had posted the Q in the
dotnet group!!
Then a few minutes later he posts in the dotnet group, "the Q is already
answered in this! group".
For me that indicates, to be nice, an IQ of lets say 30...

But ofcause, posting a reply to a dotnet Q in a dotnet group can't be half
as helpful as posting it here!

/Henning



Wed, 14 Mar 2012 22:17:53 GMT  
 
 [ 14 post ] 

 Relevant Pages 

1. Tough question for VB experts...

2. Attention Access Experts, this one is tough...

3. tough one for you experts

4. tough one for you experts

5. tough one for you experts out there...

6. tough question for gurus!

7. Tough questions...

8. Mathmatical Genious Needed for this tough question

9. TOUGH Question - Late Bound COM objects and VB.NET

10. tough question for powerbasic

11. a few tough questions

12. a few tough questions

 

 
Powered by phpBB® Forum Software