Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

SQL Search LIKE VB.net

drkgme

Proficient
Advanced Member
Messages
281
Reaction score
0
Points
26
Paano po search sql with LIKE gamit yung naka parameter?

ganito po yung gamit kong code kaso hindi gumagana:

sql_Search = "SELECT tblinfo.emp_no, tblinfo.lname, tblinfo.fname, tblinfo.bday, tblinfo.gender, tblinfo.status, tblemp.emp_status, tblemp.emp_position, tblemp.emp_department FROM tblinfo LEFT JOIN tblemp ON tblinfo.emp_no = tblemp.emp_no WHERE tblinfo.fname LIKE @SearchAs "

oledcommand.Parameters.AddWithValue("@SearchAs", OleDbType.VarWChar).Value = txtSearch.Text


Thanks sa mga tutulong.
 
Paano po search sql with LIKE gamit yung naka parameter?

ganito po yung gamit kong code kaso hindi gumagana:

sql_Search = "SELECT tblinfo.emp_no, tblinfo.lname, tblinfo.fname, tblinfo.bday, tblinfo.gender, tblinfo.status, tblemp.emp_status, tblemp.emp_position, tblemp.emp_department FROM tblinfo LEFT JOIN tblemp ON tblinfo.emp_no = tblemp.emp_no WHERE tblinfo.fname LIKE @SearchAs "

oledcommand.Parameters.AddWithValue("@SearchAs", OleDbType.VarWChar).Value = txtSearch.Text


Thanks sa mga tutulong.

SELECT tblinfo.emp_no, tblinfo.lname, tblinfo.fname, tblinfo.bday, tblinfo.gender, tblinfo.status, tblemp.emp_status, tblemp.emp_position, tblemp.emp_department FROM tblinfo LEFT JOIN tblemp ON tblinfo.emp_no = tblemp.emp_no WHERE tblinfo.fname LIKE '%' + @SearchAs + '%'
 
Last edited:
SELECT tblinfo.emp_no, tblinfo.lname, tblinfo.fname, tblinfo.bday, tblinfo.gender, tblinfo.status, tblemp.emp_status, tblemp.emp_position, tblemp.emp_department FROM tblinfo LEFT JOIN tblemp ON tblinfo.emp_no = tblemp.emp_no WHERE tblinfo.fname LIKE '%' + @SearchAs + '%'


thanks po sa reply.. hindi pa rin po working yung code, meron pa rin pong error message:
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll

Additional information: No value given for one or more required parameters.


Working naman pag ganito lang yung code:
"SELECT tblinfo.emp_no, tblinfo.lname, tblinfo.fname, tblinfo.bday, tblinfo.gender, tblinfo.status, tblemp.emp_status, tblemp.emp_position, tblemp.emp_department FROM tblinfo LEFT JOIN tblemp ON tblinfo.emp_no = tblemp.emp_no WHERE tblinfo.fname LIKE '%" & searchAs & "%'"
 
ql_Search = "SELECT tblinfo.emp_no, tblinfo.lname, tblinfo.fname, tblinfo.bday, tblinfo.gender, tblinfo.status, tblemp.emp_status, tblemp.emp_position, tblemp.emp_department FROM tblinfo LEFT JOIN tblemp ON tblinfo.emp_no = tblemp.emp_no WHERE tblinfo.fname LIKE @SearchAs "

oledcommand.Parameters.AddWithValue("@SearchAs", OleDbType.VarWChar).Value ="%" & txtSearch.Text &"%"

try mo to sir
 
Back
Top Bottom