Hi there,
I an trying to put multiple 'OR' sql statement in vb for to display data for a table holding transaction data, but It is not working.
I want that query should search the entire table along with date condition. Below is my code
I an trying to put multiple 'OR' sql statement in vb for to display data for a table holding transaction data, but It is not working.
I want that query should search the entire table along with date condition. Below is my code
Code:
Dim search As String = "select * from transactions where txn_date between @dt_from and @dt_to and txn_number like '%" & tx_txn_criteria.Text & "%' or txn_remarks like '%" & tx_txn_criteria.Text & "%'"
Dim cmd As New SqlCommand(search, con)
Dim da As New SqlDataAdapter(cmd)
cmd.Parameters.AddWithValue("@dt_from", SqlDbType.DateTime).Value = dt_from.Value
cmd.Parameters.AddWithValue("@dt_to", SqlDbType.DateTime).Value = dt_to.Value
Dim table As New DataTable()
da.Fill(table)
If table.Rows.Count > 0 Then
DataGridView1.DataSource = table
Else
MessageBox.Show("No Data Found")
End If
con.Close()