vb.net Code:
Dim dbCMD As New OleDb.OleDbCommand With {.Connection = dbConn, .CommandText = _
<SQL>
SELECT TypeOfConnection
FROM tblNameHere
WHERE WordCombination = ?
</SQL>.Value}
Dim pWord1 As New OleDbParameter With {.DbType = DbType.String, .ParameterName = "@P1"}
Dim dbReader As OleDb.OleDbDataReader
'This line sets pWord1 to TextBox1
pWord1.Value = TextBox1.Text
'In short, this line changes the ? in the above SQL to whatever is in TextBox1
dbCMD.Parameters.Add(pWord1)
Try
'This line actually gets the information
dbReader = dbCMD.ExecuteReader
Catch ex As Exception
'An error happened when trying to retrieve from the database
Debug.Print ex.MEssage
End Try
vb.net Code:
Dim isFound As Boolean = False
Dim i As Integer = 0
b.MoveFirst()
TextBox2.Text = String.Empty
For i = 0 To b.Count - 1
If TextBox1.Text.Contains(DataGridView1.Item(1, DataGridView1.CurrentRow.Index).Value.ToString) Then
isFound = True
TextBox2.Text &= DataGridView1.Item(2, DataGridView1.CurrentRow.Index).Value.ToString & _
" " & TextBox1.Text & Environment.NewLine
End If
b.MoveNext()
Next