I have a textbox and a datagrid. I am trying to enter a last name into the textbox and have that return the entire record from that last name into the datagrid from an oracle database. The code below currently returns all records in the table and is not searching by the last name.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myString As String
Dim myArg As String
Dim mysql As String
Dim myConn As New OleDb.OleDbConnection()
' Create new connection
myString = "Provider=msdaora;Data Source=XXXX;User Id=XXXX;Password=XXXX;"
myConn.ConnectionString = myString
myArg = TextBox1.Text
mysql = "select * from table1 where lastname like '%'"
Try
myConn.Open()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Dim myDataadapter As New OleDb.OleDbDataAdapter(mysql, myConn)
Dim myDs As New DataSet
myDataadapter.Fill(myDs, "customer")
Dim prmLName As New OleDb.OleDbParameter()
prmLName.Direction = ParameterDirection.Input
prmLName.Size = "10"
prmLName.Value = TextBox1.Text
DataGridView1.DataSource = myDs
DataGridView1.DataMember = "customer"
End Sub
End Class