|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
prompt user to select from recordset.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 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 > > 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 >> >> > > 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. -- Show quote____________________________________ 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 >>> >>> >> >> > > 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 Why not? You give each value its own parameter, like:
IN (@Param1, @Param2, ...) -- Show quoteMiha Markic [MVP C#, INETA Country Leader for Slovenia] RightHand .NET consulting & development www.rthand.com Blog: http://cs.rthand.com/blogs/blog_with_righthand/ "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 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 "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message If you have a better idea, tell us.news:%23lTTOUrJIHA.1620@TK2MSFTNGP03.phx.gbl... > > Miha > > I think that it a very lot of work and will work slow The other variation is to process [comma] delimited strings on the server which involves t-sql code. > Everybody would be glad. But this is the current state of the affairs.>> 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) -- 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/ 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/ 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 This is the results from you after your interceptions .>>>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. > If you have a better idea, tell us. Do you think that I ask a question to Bill as I have the answer? The > The other variation is to process [comma] delimited strings on the server > which involves t-sql code. > solution you gave was in fact explicit in my question. Cor 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. -- Show quote____________________________________ 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 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 > 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 >>>> >>>> >>> >>> >> >> > You always know how to push my buttons... ;(
-- Show quote____________________________________ 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 >>>>> >>>>> >>>> >>>> >>> >>> >> > > 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 >>>>>> >>>>>> >>>>> >>>>> >>>> >>>> >>> >> >> > |
|||||||||||||||||||||||