Using a textbox as a variable

levyuk

Well-known member
Joined
Jun 7, 2004
Messages
313
Location
Wales, UK
Programming Experience
3-5
Hi
I have this code
VB.NET:
cmdSelect = New OleDbCommand( "SELECT [recipes].[ID], [recipes].[Name] FROM [recipes] WHERE Name LIKE 'a%'", conNorthwind )

What I would like to do is change the LIKE part so that the variable to search by is equal to some text from a textbox e.g.

cmdSelect = New OleDbCommand( "SELECT [recipes].[ID], [recipes].[Name] FROM [recipes] WHERE Name LIKE '" & TextBoxName.Text "%'", conNorthwind )

Does anyone know how to do this?
 
Solved it :D

cmdSelect = New OleDbCommand( "SELECT [recipes].[ID], [recipes].[Name] FROM [recipes] WHERE Name LIKE '" & TextBox1.Text & "%'", conNorthwind )
 
Back
Top