Dim connection As OleDb.OleDbConnection = New OleDbConnection connection.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & System.Environment.CurrentDirectory & "\InventSystem.accdb" connection.Open() Dim da As OleDb.OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM Items WHERE Barcode Like '%" & TextBox1.Text & "%' ", connection) Dim ds As New DataTable da.Fill(ds) If ds.Rows.Count = 0 Then MessageBox.Show("Record not Found") End If connection.Dispose()
Using connection As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|AppData|\InventSystem.accdb") Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM Items WHERE Barcode Like '%' + @find + '%'", connection) da.SelectCommand.Parameters.AddWithValue("@find", TextBox1.Text) Dim table As New DataTable() da.Fill(table) If table.Rows.Count = 0 Then MessageBox.Show("Record not found") Else ' TODO: Show the returned rows somewhere... End If End Using
Dim qry As String = "SELECT * FROM Items WHERE Barcode Like '*@find*';"
*
%
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)