Welcome to Dream.In.Code
Become a VB Expert!

Join 137,228 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,912 people online right now. Registration is fast and FREE... Join Now!




Select database row by textbox

 
Reply to this topicStart new topic

Select database row by textbox

oldgolfer
17 Mar, 2007 - 08:22 PM
Post #1

New D.I.C Head
*

Joined: 13 Nov, 2006
Posts: 20



Thanked: 1 times
My Contributions
I am very new to programming and I have got stuck. I have searched for an answer but all those i find are very hard to understand. I wish to select and delete a row from a database using the textbox text that is entered by user. the code I have so far is:-
CODE

[Dim drCurrent() As DataRow
drCurrent = DeleteNamesDataSet.AllNames.Select("Name = 'Smith'")
drCurrent(0).Delete()
]
'This works if I enter a name in the code e.g Smith etc, but how do i find correct row using name in txtName.Text????
If someone could just point me in the right direction blink.gif
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Select Database Row By Textbox
17 Mar, 2007 - 09:20 PM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,984



Thanked: 44 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
You can do that by replacing Smith with the textbox value that is supplied using the Text property. You just need to concatenate it using the & ampersand into the String. Just replace TextBox1 with the actual name of your textbox. It is important to make sure the & TextBox1.Text & is not inside the quotes.
CODE

drCurrent = DeleteNamesDataSet.AllNames.Select("Name = '" & TextBox1.Text & "'")

User is online!Profile CardPM
+Quote Post

oldgolfer
RE: Select Database Row By Textbox
17 Mar, 2007 - 09:33 PM
Post #3

New D.I.C Head
*

Joined: 13 Nov, 2006
Posts: 20



Thanked: 1 times
My Contributions
QUOTE(jayman9 @ 17 Mar, 2007 - 10:20 PM) *

You can do that by replacing Smith with the textbox value that is supplied using the Text property. You just need to concatenate it using the & ampersand into the String. Just replace TextBox1 with the actual name of your textbox. It is important to make sure the & TextBox1.Text & is not inside the quotes.
CODE

drCurrent = DeleteNamesDataSet.AllNames.Select("Name = '" & TextBox1.Text & "'")



That worked a treat. Thank you very much. I don't think I have seen that solution anywhere I have looked. I wish there were more people ready to help like you guys. thx again

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/4/08 02:55PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month