Dim cm As New System.Data.OleDb.OleDbCommand Dim rd As System.Data.OleDb.OleDbDataReader Dim Conn As OleDbConnection Private Sub txtSearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSearch.TextChanged Dim adp As New Data.OleDb.OleDbDataAdapter Dim ds As New DataSet Dim dv As New DataView If txtSearch.Text = Nothing Then Call LoadGrid() Exit Sub Else Conn.Open() cm.Connection = Conn cm.CommandText = "select * from admin_table where admin_Name like '" & txtSearch.Text & "%' OR " cm.CommandText = "select * from admin_table where admin_Username like '" & txtSearch.Text & "%'" rd = cm.ExecuteReader() Conn.Close() adp.SelectCommand = cm adp.Fill(ds, "dataset") dv.Table = ds.Tables(0) dv.Sort = "admin_ID" gridAdmin.DataSource = dv gridAdmin.Refresh() End If End Sub
Error with SQL statement while querying the DB
Page 1 of 11 Replies - 606 Views - Last Post: 29 May 2009 - 12:31 PM
#1
Error with SQL statement while querying the DB
Posted 28 May 2009 - 11:32 PM
Hello, I have some sql statement error while querying the DB and to display the result on a data grid view. Could someone check the codes below and let me know the problem with the codes. Thank you.
Replies To: Error with SQL statement while querying the DB
#2
Re: Error with SQL statement while querying the DB
Posted 29 May 2009 - 12:31 PM
Hello,
are you trying to get the data if the admin_Name is like *** or admin_Username is like ***
if it so?,your select statement is wrong
just type it as you say it
are you trying to get the data if the admin_Name is like *** or admin_Username is like ***
if it so?,your select statement is wrong
just type it as you say it
select * from admin_table where admin_Name like '" & txtSearch.Text & "%' OR admin_Username like '" & txtSearch.Text & "%'"
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|