Home All Groups Group Topic Archive Search About

prompt user to select from recordset.

Author
13 Nov 2007 8:56 PM
Kevin O'Brien
Hey guys,

I am querying a sql database for a matches using wild cards.  If I return
more than one record I want to prompt the user to choose the best match.
What is the best way to do this?  I thought I could put the matching records
into a label and have the user select the item that they want but when using
that method I am only getting the values in the label item and not the
recordID.  Any help is greatly appreciated.  My code is below.

Thanks,

Kevin





thisConnection.Open()

Dim scalarCommand As New SqlCommand("Select Count(*) FROM Users where
FirstName like '" & TextBox2.Text & "%' OR LastName like '" & TextBox2.Text
& "%'", thisConnection)

Dim intCount = scalarCommand.ExecuteScalar()

TextBox99.Text = intCount.ToString()

If intCount > 1 Then

End If

Author
13 Nov 2007 9:15 PM
W.G. Ryan
If you want to use a Label - you can store it in the Tag property - or if
you want to keep it a little more slick, subclass Label and add a RecordId
property to it.

From a UI point of view, i'd recommend using some control that supports
complex binding. If this is Winforms, you can use a Combobox or a ListBox to
name two.  You can set the DisplayMember to the LastName or whatever it
currently is (whatever value you want the users to see) and set the
ValueMember to the RecordID.  You can then access it using the
ListBox/Combbox.SelectedValue property.

If I understand your issue correctly, one of these should work whichever
control you decide on. if I misunderstood , was vague or was unclear, just
let me know and I'll try again.

Cheers,

bill
Show quote
"Kevin O'Brien" <kevin***@usa.net> wrote in message
news:OUrWqejJIHA.536@TK2MSFTNGP06.phx.gbl...
> Hey guys,
>
> I am querying a sql database for a matches using wild cards.  If I return
> more than one record I want to prompt the user to choose the best match.
> What is the best way to do this?  I thought I could put the matching
> records into a label and have the user select the item that they want but
> when using that method I am only getting the values in the label item and
> not the recordID.  Any help is greatly appreciated.  My code is below.
>
> Thanks,
>
> Kevin
>
>
>
>
>
> thisConnection.Open()
>
> Dim scalarCommand As New SqlCommand("Select Count(*) FROM Users where
> FirstName like '" & TextBox2.Text & "%' OR LastName like '" &
> TextBox2.Text & "%'", thisConnection)
>
> Dim intCount = scalarCommand.ExecuteScalar()
>
> TextBox99.Text = intCount.ToString()
>
> If intCount > 1 Then
>
> End If
>
>
Author
13 Nov 2007 9:39 PM
Kevin O'Brien
Hey Bill,

Thanks for the quick response.  I'll try out the listbox.  I haven't really
used it so I'll give it a shot and let you know how I make out.

thank you,
Kevin



Show quote
"W.G. Ryan" <WilliamRyan@nospam.gmail.com> wrote in message
news:u1aqapjJIHA.5764@TK2MSFTNGP06.phx.gbl...
> If you want to use a Label - you can store it in the Tag property - or if
> you want to keep it a little more slick, subclass Label and add a RecordId
> property to it.
>
> From a UI point of view, i'd recommend using some control that supports
> complex binding. If this is Winforms, you can use a Combobox or a ListBox
> to name two.  You can set the DisplayMember to the LastName or whatever it
> currently is (whatever value you want the users to see) and set the
> ValueMember to the RecordID.  You can then access it using the
> ListBox/Combbox.SelectedValue property.
>
> If I understand your issue correctly, one of these should work whichever
> control you decide on. if I misunderstood , was vague or was unclear, just
> let me know and I'll try again.
>
> Cheers,
>
> bill
> "Kevin O'Brien" <kevin***@usa.net> wrote in message
> news:OUrWqejJIHA.536@TK2MSFTNGP06.phx.gbl...
>> Hey guys,
>>
>> I am querying a sql database for a matches using wild cards.  If I return
>> more than one record I want to prompt the user to choose the best match.
>> What is the best way to do this?  I thought I could put the matching
>> records into a label and have the user select the item that they want but
>> when using that method I am only getting the values in the label item and
>> not the recordID.  Any help is greatly appreciated.  My code is below.
>>
>> Thanks,
>>
>> Kevin
>>
>>
>>
>>
>>
>> thisConnection.Open()
>>
>> Dim scalarCommand As New SqlCommand("Select Count(*) FROM Users where
>> FirstName like '" & TextBox2.Text & "%' OR LastName like '" &
>> TextBox2.Text & "%'", thisConnection)
>>
>> Dim intCount = scalarCommand.ExecuteScalar()
>>
>> TextBox99.Text = intCount.ToString()
>>
>> If intCount > 1 Then
>>
>> End If
>>
>>
>
>
Author
13 Nov 2007 11:25 PM
William Vaughn
Of course, your application will be subject to SQL injection attacks. Before
you finish be sure to replace the concatenated SQL with a Parameter
query--better yet a stored procedure.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant, Dad, Grandpa
Microsoft MVP
INETA Speaker
www.betav.com
www.betav.com/blog/billva
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

Show quote
"Kevin O'Brien" <kevin***@usa.net> wrote in message
news:egunk2jJIHA.4880@TK2MSFTNGP03.phx.gbl...
> Hey Bill,
>
> Thanks for the quick response.  I'll try out the listbox.  I haven't
> really used it so I'll give it a shot and let you know how I make out.
>
> thank you,
> Kevin
>
>
>
> "W.G. Ryan" <WilliamRyan@nospam.gmail.com> wrote in message
> news:u1aqapjJIHA.5764@TK2MSFTNGP06.phx.gbl...
>> If you want to use a Label - you can store it in the Tag property - or if
>> you want to keep it a little more slick, subclass Label and add a
>> RecordId property to it.
>>
>> From a UI point of view, i'd recommend using some control that supports
>> complex binding. If this is Winforms, you can use a Combobox or a ListBox
>> to name two.  You can set the DisplayMember to the LastName or whatever
>> it currently is (whatever value you want the users to see) and set the
>> ValueMember to the RecordID.  You can then access it using the
>> ListBox/Combbox.SelectedValue property.
>>
>> If I understand your issue correctly, one of these should work whichever
>> control you decide on. if I misunderstood , was vague or was unclear,
>> just let me know and I'll try again.
>>
>> Cheers,
>>
>> bill
>> "Kevin O'Brien" <kevin***@usa.net> wrote in message
>> news:OUrWqejJIHA.536@TK2MSFTNGP06.phx.gbl...
>>> Hey guys,
>>>
>>> I am querying a sql database for a matches using wild cards.  If I
>>> return more than one record I want to prompt the user to choose the best
>>> match. What is the best way to do this?  I thought I could put the
>>> matching records into a label and have the user select the item that
>>> they want but when using that method I am only getting the values in the
>>> label item and not the recordID.  Any help is greatly appreciated.  My
>>> code is below.
>>>
>>> Thanks,
>>>
>>> Kevin
>>>
>>>
>>>
>>>
>>>
>>> thisConnection.Open()
>>>
>>> Dim scalarCommand As New SqlCommand("Select Count(*) FROM Users where
>>> FirstName like '" & TextBox2.Text & "%' OR LastName like '" &
>>> TextBox2.Text & "%'", thisConnection)
>>>
>>> Dim intCount = scalarCommand.ExecuteScalar()
>>>
>>> TextBox99.Text = intCount.ToString()
>>>
>>> If intCount > 1 Then
>>>
>>> End If
>>>
>>>
>>
>>
>
>
Author
14 Nov 2007 5:59 AM
Cor Ligthert[MVP]
Bill,

As far as I know is it impossible to use the IN or an infinit string of OR's
with parameters.
(in fact a not limited by length array of parameters).

Do you have a direct solution to that. Otherwise maybe a good target for you
to realise that for us.

Cor
Author
14 Nov 2007 9:48 AM
Miha Markic
Why not? You give each value its own parameter, like:
IN (@Param1, @Param2, ...)

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Show quote
"Cor Ligthert[MVP]" <notmyfirstn***@planet.nl> wrote in message
news:5E43EF7D-39E3-486C-8F8D-6B70583CF9E8@microsoft.com...
> Bill,
>
> As far as I know is it impossible to use the IN or an infinit string of
> OR's with parameters.
> (in fact a not limited by length array of parameters).
>
> Do you have a direct solution to that. Otherwise maybe a good target for
> you to realise that for us.
>
> Cor
Author
14 Nov 2007 11:52 AM
Cor Ligthert [MVP]
Miha

I think that it a very lot of work and will work slow

> IN (@Param1, @Param2, ...)
>
IN (@Param1, @Param2, ..........................@Param10000000000000)

(In C# or VB.Net I can do this in a loop, that is not the problem, however I
would be more glad if there was a parameterArray in SQL for that, or a
solution like that)

Cor
Author
14 Nov 2007 12:45 PM
Miha Markic
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:%23lTTOUrJIHA.1620@TK2MSFTNGP03.phx.gbl...
>
> Miha
>
> I think that it a very lot of work and will work slow

If you have a better idea, tell us.
The other variation is to process [comma] delimited strings on the server
which involves t-sql code.

>
>> IN (@Param1, @Param2, ...)
>>
> IN (@Param1, @Param2, ..........................@Param10000000000000)
>
> (In C# or VB.Net I can do this in a loop, that is not the problem, however
> I would be more glad if there was a parameterArray in SQL for that, or a
> solution like that)

Everybody would be glad. But this is the current state of the affairs.
--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
Author
14 Nov 2007 3:47 PM
W.G. Ryan
I always use the T-Sql parsing b/c well, I'm good like that and gotta
practice what I preach
http://support.microsoft.com/default.aspx?scid=kb;en-us;555167

But I'm liking the client side approach you recommend.  Might have to give
that a try.
Show quote
"Miha Markic" <miha at rthand com> wrote in message
news:uY9i8yrJIHA.4196@TK2MSFTNGP04.phx.gbl...
>
> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
> news:%23lTTOUrJIHA.1620@TK2MSFTNGP03.phx.gbl...
>>
>> Miha
>>
>> I think that it a very lot of work and will work slow
>
> If you have a better idea, tell us.
> The other variation is to process [comma] delimited strings on the server
> which involves t-sql code.
>
>>
>>> IN (@Param1, @Param2, ...)
>>>
>> IN (@Param1, @Param2, ..........................@Param10000000000000)
>>
>> (In C# or VB.Net I can do this in a loop, that is not the problem,
>> however I would be more glad if there was a parameterArray in SQL for
>> that, or a solution like that)
>
> Everybody would be glad. But this is the current state of the affairs.
> --
> Miha Markic [MVP C#, INETA Country Leader for Slovenia]
> RightHand .NET consulting & development www.rthand.com
> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
Author
14 Nov 2007 6:44 PM
Cor Ligthert[MVP]
Miha,

Is this a kind of joke or somehting from you, I did not recognise it as
that.

This was my message related to the answer from Bill

>>>As far as I know is it impossible to use the IN or an infinit string of
>>>OR's with parameters.
>>>(in fact a not limited by length array of parameters).

>>>Do you have a direct solution to that. Otherwise maybe a good target for
>>>you to realise that for us.

This is the results from you after your interceptions .

> If you have a better idea, tell us.
> The other variation is to process [comma] delimited strings on the server
> which involves t-sql code.
>
Do you think that I ask a question to Bill as I have the answer? The
solution you gave was in fact explicit in my question.

Cor
Author
14 Nov 2007 6:51 PM
William Vaughn
Ah, this is a well documented (outside of the MS doc) issue that has a
number of clean solutions.
First, write a TSQL delimited string to Table value function to pass to the
IN as in
    ... WHERE X IN (SELECT yy FROM MyTSQLDelimitedStringToTVF)
Or... write the code in a CLR function. I have examples of both in my book.
While the CLR function takes about 5 lines of code (and the TSQL takes about
40 lines), the CLR function is no faster.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant, Dad, Grandpa
Microsoft MVP
INETA Speaker
www.betav.com
www.betav.com/blog/billva
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

Show quote
"Cor Ligthert[MVP]" <notmyfirstn***@planet.nl> wrote in message
news:5E43EF7D-39E3-486C-8F8D-6B70583CF9E8@microsoft.com...
> Bill,
>
> As far as I know is it impossible to use the IN or an infinit string of
> OR's with parameters.
> (in fact a not limited by length array of parameters).
>
> Do you have a direct solution to that. Otherwise maybe a good target for
> you to realise that for us.
>
> Cor
Author
15 Nov 2007 10:19 PM
W.G. Ryan
When i was first learning ADO.NET, the DBA at my company busted me using
concatenated sql.  He got all over me about it and I countered that there
was no elegant way to do it as far as I knew.  he responded that "There's no
elegant way for me to restore the database without looking like a complete
jacka33 after some hacker decides to have some fun with it"  .  That pretty
much settled it for me ;-)
Show quote
"William Vaughn" <billvaNoSPAM@betav.com> wrote in message
news:82880C1B-FF04-4858-B4DB-829C876BA96D@microsoft.com...
> Ah, this is a well documented (outside of the MS doc) issue that has a
> number of clean solutions.
> First, write a TSQL delimited string to Table value function to pass to
> the IN as in
>    ... WHERE X IN (SELECT yy FROM MyTSQLDelimitedStringToTVF)
> Or... write the code in a CLR function. I have examples of both in my
> book. While the CLR function takes about 5 lines of code (and the TSQL
> takes about 40 lines), the CLR function is no faster.
>
> --
> ____________________________________
> William (Bill) Vaughn
> Author, Mentor, Consultant, Dad, Grandpa
> Microsoft MVP
> INETA Speaker
> www.betav.com
> www.betav.com/blog/billva
> Please reply only to the newsgroup so that others can benefit.
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> __________________________________
> Visit www.hitchhikerguides.net to get more information on my latest book:
> Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
> and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
> -----------------------------------------------------------------------------------------------------------------------
>
> "Cor Ligthert[MVP]" <notmyfirstn***@planet.nl> wrote in message
> news:5E43EF7D-39E3-486C-8F8D-6B70583CF9E8@microsoft.com...
>> Bill,
>>
>> As far as I know is it impossible to use the IN or an infinit string of
>> OR's with parameters.
>> (in fact a not limited by length array of parameters).
>>
>> Do you have a direct solution to that. Otherwise maybe a good target for
>> you to realise that for us.
>>
>> Cor
>
Author
14 Nov 2007 6:28 PM
W.G. Ryan
or... LOL, use LINQ ;-)
Show quote
"William Vaughn" <billvaNoSPAM@betav.com> wrote in message
news:9A941BD9-58A2-4B30-9329-D01C8E767326@microsoft.com...
> Of course, your application will be subject to SQL injection attacks.
> Before you finish be sure to replace the concatenated SQL with a Parameter
> query--better yet a stored procedure.
>
> --
> ____________________________________
> William (Bill) Vaughn
> Author, Mentor, Consultant, Dad, Grandpa
> Microsoft MVP
> INETA Speaker
> www.betav.com
> www.betav.com/blog/billva
> Please reply only to the newsgroup so that others can benefit.
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> __________________________________
> Visit www.hitchhikerguides.net to get more information on my latest book:
> Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
> and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
> -----------------------------------------------------------------------------------------------------------------------
>
> "Kevin O'Brien" <kevin***@usa.net> wrote in message
> news:egunk2jJIHA.4880@TK2MSFTNGP03.phx.gbl...
>> Hey Bill,
>>
>> Thanks for the quick response.  I'll try out the listbox.  I haven't
>> really used it so I'll give it a shot and let you know how I make out.
>>
>> thank you,
>> Kevin
>>
>>
>>
>> "W.G. Ryan" <WilliamRyan@nospam.gmail.com> wrote in message
>> news:u1aqapjJIHA.5764@TK2MSFTNGP06.phx.gbl...
>>> If you want to use a Label - you can store it in the Tag property - or
>>> if you want to keep it a little more slick, subclass Label and add a
>>> RecordId property to it.
>>>
>>> From a UI point of view, i'd recommend using some control that supports
>>> complex binding. If this is Winforms, you can use a Combobox or a
>>> ListBox to name two.  You can set the DisplayMember to the LastName or
>>> whatever it currently is (whatever value you want the users to see) and
>>> set the ValueMember to the RecordID.  You can then access it using the
>>> ListBox/Combbox.SelectedValue property.
>>>
>>> If I understand your issue correctly, one of these should work whichever
>>> control you decide on. if I misunderstood , was vague or was unclear,
>>> just let me know and I'll try again.
>>>
>>> Cheers,
>>>
>>> bill
>>> "Kevin O'Brien" <kevin***@usa.net> wrote in message
>>> news:OUrWqejJIHA.536@TK2MSFTNGP06.phx.gbl...
>>>> Hey guys,
>>>>
>>>> I am querying a sql database for a matches using wild cards.  If I
>>>> return more than one record I want to prompt the user to choose the
>>>> best match. What is the best way to do this?  I thought I could put the
>>>> matching records into a label and have the user select the item that
>>>> they want but when using that method I am only getting the values in
>>>> the label item and not the recordID.  Any help is greatly appreciated.
>>>> My code is below.
>>>>
>>>> Thanks,
>>>>
>>>> Kevin
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> thisConnection.Open()
>>>>
>>>> Dim scalarCommand As New SqlCommand("Select Count(*) FROM Users where
>>>> FirstName like '" & TextBox2.Text & "%' OR LastName like '" &
>>>> TextBox2.Text & "%'", thisConnection)
>>>>
>>>> Dim intCount = scalarCommand.ExecuteScalar()
>>>>
>>>> TextBox99.Text = intCount.ToString()
>>>>
>>>> If intCount > 1 Then
>>>>
>>>> End If
>>>>
>>>>
>>>
>>>
>>
>>
>
Author
14 Nov 2007 6:48 PM
William Vaughn
You always know how to push my buttons... ;(

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant, Dad, Grandpa
Microsoft MVP
INETA Speaker
www.betav.com
www.betav.com/blog/billva
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

Show quote
"W.G. Ryan" <WilliamRyan@nospam.gmail.com> wrote in message
news:%23gw34wuJIHA.4688@TK2MSFTNGP06.phx.gbl...
> or... LOL, use LINQ ;-)
> "William Vaughn" <billvaNoSPAM@betav.com> wrote in message
> news:9A941BD9-58A2-4B30-9329-D01C8E767326@microsoft.com...
>> Of course, your application will be subject to SQL injection attacks.
>> Before you finish be sure to replace the concatenated SQL with a
>> Parameter query--better yet a stored procedure.
>>
>> --
>> ____________________________________
>> William (Bill) Vaughn
>> Author, Mentor, Consultant, Dad, Grandpa
>> Microsoft MVP
>> INETA Speaker
>> www.betav.com
>> www.betav.com/blog/billva
>> Please reply only to the newsgroup so that others can benefit.
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>> __________________________________
>> Visit www.hitchhikerguides.net to get more information on my latest book:
>> Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
>> and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
>> -----------------------------------------------------------------------------------------------------------------------
>>
>> "Kevin O'Brien" <kevin***@usa.net> wrote in message
>> news:egunk2jJIHA.4880@TK2MSFTNGP03.phx.gbl...
>>> Hey Bill,
>>>
>>> Thanks for the quick response.  I'll try out the listbox.  I haven't
>>> really used it so I'll give it a shot and let you know how I make out.
>>>
>>> thank you,
>>> Kevin
>>>
>>>
>>>
>>> "W.G. Ryan" <WilliamRyan@nospam.gmail.com> wrote in message
>>> news:u1aqapjJIHA.5764@TK2MSFTNGP06.phx.gbl...
>>>> If you want to use a Label - you can store it in the Tag property - or
>>>> if you want to keep it a little more slick, subclass Label and add a
>>>> RecordId property to it.
>>>>
>>>> From a UI point of view, i'd recommend using some control that supports
>>>> complex binding. If this is Winforms, you can use a Combobox or a
>>>> ListBox to name two.  You can set the DisplayMember to the LastName or
>>>> whatever it currently is (whatever value you want the users to see) and
>>>> set the ValueMember to the RecordID.  You can then access it using the
>>>> ListBox/Combbox.SelectedValue property.
>>>>
>>>> If I understand your issue correctly, one of these should work
>>>> whichever control you decide on. if I misunderstood , was vague or was
>>>> unclear, just let me know and I'll try again.
>>>>
>>>> Cheers,
>>>>
>>>> bill
>>>> "Kevin O'Brien" <kevin***@usa.net> wrote in message
>>>> news:OUrWqejJIHA.536@TK2MSFTNGP06.phx.gbl...
>>>>> Hey guys,
>>>>>
>>>>> I am querying a sql database for a matches using wild cards.  If I
>>>>> return more than one record I want to prompt the user to choose the
>>>>> best match. What is the best way to do this?  I thought I could put
>>>>> the matching records into a label and have the user select the item
>>>>> that they want but when using that method I am only getting the values
>>>>> in the label item and not the recordID.  Any help is greatly
>>>>> appreciated. My code is below.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Kevin
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> thisConnection.Open()
>>>>>
>>>>> Dim scalarCommand As New SqlCommand("Select Count(*) FROM Users where
>>>>> FirstName like '" & TextBox2.Text & "%' OR LastName like '" &
>>>>> TextBox2.Text & "%'", thisConnection)
>>>>>
>>>>> Dim intCount = scalarCommand.ExecuteScalar()
>>>>>
>>>>> TextBox99.Text = intCount.ToString()
>>>>>
>>>>> If intCount > 1 Then
>>>>>
>>>>> End If
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>
>
Author
15 Nov 2007 10:14 PM
W.G. Ryan
Only in the same way a yapping Chihuahua can push a champion Rottweiler's
buttons. Although being a cat lover, you might not appreciate the Rotty
reference and I'm about 70 lbs to fat for the Chihuahua analogy to fit ;-)
Show quote
"William Vaughn" <billvaNoSPAM@betav.com> wrote in message
news:06182564-2A7E-4724-8AE5-EAD001726E52@microsoft.com...
> You always know how to push my buttons... ;(
>
> --
> ____________________________________
> William (Bill) Vaughn
> Author, Mentor, Consultant, Dad, Grandpa
> Microsoft MVP
> INETA Speaker
> www.betav.com
> www.betav.com/blog/billva
> Please reply only to the newsgroup so that others can benefit.
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> __________________________________
> Visit www.hitchhikerguides.net to get more information on my latest book:
> Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
> and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
> -----------------------------------------------------------------------------------------------------------------------
>
> "W.G. Ryan" <WilliamRyan@nospam.gmail.com> wrote in message
> news:%23gw34wuJIHA.4688@TK2MSFTNGP06.phx.gbl...
>> or... LOL, use LINQ ;-)
>> "William Vaughn" <billvaNoSPAM@betav.com> wrote in message
>> news:9A941BD9-58A2-4B30-9329-D01C8E767326@microsoft.com...
>>> Of course, your application will be subject to SQL injection attacks.
>>> Before you finish be sure to replace the concatenated SQL with a
>>> Parameter query--better yet a stored procedure.
>>>
>>> --
>>> ____________________________________
>>> William (Bill) Vaughn
>>> Author, Mentor, Consultant, Dad, Grandpa
>>> Microsoft MVP
>>> INETA Speaker
>>> www.betav.com
>>> www.betav.com/blog/billva
>>> Please reply only to the newsgroup so that others can benefit.
>>> This posting is provided "AS IS" with no warranties, and confers no
>>> rights.
>>> __________________________________
>>> Visit www.hitchhikerguides.net to get more information on my latest
>>> book:
>>> Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
>>> and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
>>> -----------------------------------------------------------------------------------------------------------------------
>>>
>>> "Kevin O'Brien" <kevin***@usa.net> wrote in message
>>> news:egunk2jJIHA.4880@TK2MSFTNGP03.phx.gbl...
>>>> Hey Bill,
>>>>
>>>> Thanks for the quick response.  I'll try out the listbox.  I haven't
>>>> really used it so I'll give it a shot and let you know how I make out.
>>>>
>>>> thank you,
>>>> Kevin
>>>>
>>>>
>>>>
>>>> "W.G. Ryan" <WilliamRyan@nospam.gmail.com> wrote in message
>>>> news:u1aqapjJIHA.5764@TK2MSFTNGP06.phx.gbl...
>>>>> If you want to use a Label - you can store it in the Tag property - or
>>>>> if you want to keep it a little more slick, subclass Label and add a
>>>>> RecordId property to it.
>>>>>
>>>>> From a UI point of view, i'd recommend using some control that
>>>>> supports complex binding. If this is Winforms, you can use a Combobox
>>>>> or a ListBox to name two.  You can set the DisplayMember to the
>>>>> LastName or whatever it currently is (whatever value you want the
>>>>> users to see) and set the ValueMember to the RecordID.  You can then
>>>>> access it using the ListBox/Combbox.SelectedValue property.
>>>>>
>>>>> If I understand your issue correctly, one of these should work
>>>>> whichever control you decide on. if I misunderstood , was vague or was
>>>>> unclear, just let me know and I'll try again.
>>>>>
>>>>> Cheers,
>>>>>
>>>>> bill
>>>>> "Kevin O'Brien" <kevin***@usa.net> wrote in message
>>>>> news:OUrWqejJIHA.536@TK2MSFTNGP06.phx.gbl...
>>>>>> Hey guys,
>>>>>>
>>>>>> I am querying a sql database for a matches using wild cards.  If I
>>>>>> return more than one record I want to prompt the user to choose the
>>>>>> best match. What is the best way to do this?  I thought I could put
>>>>>> the matching records into a label and have the user select the item
>>>>>> that they want but when using that method I am only getting the
>>>>>> values in the label item and not the recordID.  Any help is greatly
>>>>>> appreciated. My code is below.
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> Kevin
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> thisConnection.Open()
>>>>>>
>>>>>> Dim scalarCommand As New SqlCommand("Select Count(*) FROM Users where
>>>>>> FirstName like '" & TextBox2.Text & "%' OR LastName like '" &
>>>>>> TextBox2.Text & "%'", thisConnection)
>>>>>>
>>>>>> Dim intCount = scalarCommand.ExecuteScalar()
>>>>>>
>>>>>> TextBox99.Text = intCount.ToString()
>>>>>>
>>>>>> If intCount > 1 Then
>>>>>>
>>>>>> End If
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>>
>
Author
14 Nov 2007 5:56 AM
Cor Ligthert[MVP]
Kevin,

If you want to use the listbox is it better to use the DataTable (in or
outside a DataSet) with AdoNet instead of the now very classic recordset.

In my idea is it impossible to bind a Listbox to a recordset.

Cor

AddThis Social Bookmark Button