Home
Forums
New posts
Search forums
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
C# Community
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
VB.NET
VB.NET General Discussion
How to search base on staff name and no?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="jue" data-source="post: 6450" data-attributes="member: 2524"><p>hi.. i have problem here. How to search staff info base on staff name and staff no? staff info will out in datagrid.</p><p>here is sample my coding.</p><p></p><p><span style="font-size: 10px"><span style="color: #0000ff">Private</span></span> <span style="font-size: 10px"><span style="color: #0000ff">Sub</span></span><span style="font-size: 10px"> searchstaffdetail()</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px"></span><span style="font-size: 10px"><span style="color: #0000ff">Dim</span></span><span style="font-size: 10px"> connString </span><span style="font-size: 10px"><span style="color: #0000ff">As</span></span> <span style="font-size: 10px"><span style="color: #0000ff">New</span></span><span style="font-size: 10px"> ConnectionString()</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px"></span><span style="font-size: 10px"><span style="color: #0000ff">Dim</span></span><span style="font-size: 10px"> oleConn </span><span style="font-size: 10px"><span style="color: #0000ff">As</span></span><span style="font-size: 10px"> OleDb.OleDbConnection</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px"></span><span style="font-size: 10px"><span style="color: #0000ff">Dim</span></span><span style="font-size: 10px"> areaData </span><span style="font-size: 10px"><span style="color: #0000ff">As</span></span><span style="font-size: 10px"> OleDb.OleDbDataAdapter</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px"></span><span style="font-size: 10px"><span style="color: #0000ff">Dim</span></span><span style="font-size: 10px"> recSet </span><span style="font-size: 10px"><span style="color: #0000ff">As</span></span> <span style="font-size: 10px"><span style="color: #0000ff">New</span></span><span style="font-size: 10px"> DataSet()</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px"></span><span style="font-size: 10px"><span style="color: #0000ff">Dim</span></span><span style="font-size: 10px"> strCon </span><span style="font-size: 10px"><span style="color: #0000ff">As</span></span> <span style="font-size: 10px"><span style="color: #0000ff">String</span></span></p><p><span style="font-size: 10px"><span style="color: #0000ff"></span></span></p><p><span style="font-size: 10px"><span style="color: #0000ff"></span></span><span style="font-size: 10px"><span style="color: #0000ff">Dim</span></span><span style="font-size: 10px"> strSQL </span><span style="font-size: 10px"><span style="color: #0000ff">As</span></span> <span style="font-size: 10px"><span style="color: #0000ff">String</span></span></p><p><span style="font-size: 10px"><span style="color: #0000ff"></span></span></p><p><span style="font-size: 10px"><span style="color: #0000ff"></span></span><span style="font-size: 10px"><span style="color: #0000ff">Dim</span></span><span style="font-size: 10px"> intCount </span><span style="font-size: 10px"><span style="color: #0000ff">As</span></span> <span style="font-size: 10px"><span style="color: #0000ff">String</span></span></p><p><span style="font-size: 10px"><span style="color: #0000ff"></span></span></p><p><span style="font-size: 10px"><span style="color: #0000ff"></span></span><span style="font-size: 10px">strCon = connString.connIHD</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px">strSQL = " select staff_no, name, dept, section " _</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px">& " from PMO_staff_info order by name "</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px"></span><span style="font-size: 10px"><span style="color: #0000ff">If</span></span><span style="font-size: 10px"> Trim(txtstaffname.Text) <> "" </span><span style="font-size: 10px"><span style="color: #0000ff">Then</span></span></p><p><span style="font-size: 10px"><span style="color: #0000ff"></span></span></p><p><span style="font-size: 10px"><span style="color: #0000ff"></span></span><span style="font-size: 10px">strSQL = strSQL & " and lower(name) like '%" & txtstaffname.Text.ToLower & "%'"</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px"></span><span style="font-size: 10px"><span style="color: #008000">''If Trim(txtstaffno.Text) <> "" Then</span></span></p><p><span style="font-size: 10px"><span style="color: #008000"></span></span></p><p><span style="font-size: 10px"><span style="color: #008000"></span></span><span style="font-size: 10px"><span style="color: #008000">'' strSQL = strSQL & " and staff_no = " & CInt(txtstaffno.Text) & ""</span></span></p><p><span style="font-size: 10px"><span style="color: #008000"></span></span></p><p><span style="font-size: 10px"><span style="color: #008000"></span></span><span style="font-size: 10px"><span style="color: #008000">'' 'ElseIf Trim(txtIC.Text) <> "" Then</span></span></p><p><span style="font-size: 10px"><span style="color: #008000"></span></span></p><p><span style="font-size: 10px"><span style="color: #008000"></span></span><span style="font-size: 10px"><span style="color: #008000">' strSQL = strSQL & " and staff_ic = " & CInt(txtIC.Text) & ""</span></span></p><p><span style="font-size: 10px"><span style="color: #008000"></span></span></p><p><span style="font-size: 10px"><span style="color: #008000"></span></span><span style="font-size: 10px"><span style="color: #0000ff">End</span></span> <span style="font-size: 10px"><span style="color: #0000ff">If</span></span></p><p><span style="font-size: 10px"><span style="color: #0000ff"></span></span></p><p><span style="font-size: 10px"><span style="color: #0000ff"></span></span><span style="font-size: 10px">strSQL = strSQL & " order by name "</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px">areaData = </span><span style="font-size: 10px"><span style="color: #0000ff">New</span></span><span style="font-size: 10px"> OleDbDataAdapter(strSQL, strCon)</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px">areaData.Fill(recSet, "staffinfo")</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px">intCount = recSet.Tables(0).Rows.Count</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px"></span><span style="font-size: 10px"><span style="color: #008000">'If intCount > 0 Then</span></span></p><p><span style="font-size: 10px"><span style="color: #008000"></span></span></p><p><span style="font-size: 10px"><span style="color: #008000"></span></span><span style="font-size: 10px">dgstaffinfo.DataSource = recSet</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px">dgstaffinfo.DataBind()</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px">dgstaffinfo.Visible = </span><span style="font-size: 10px"><span style="color: #0000ff">True</span></span></p><p><span style="font-size: 10px"><span style="color: #0000ff"></span></span></p><p><span style="font-size: 10px"><span style="color: #0000ff"></span></span><span style="font-size: 10px">lblmessageerror.Visible = </span><span style="font-size: 10px"><span style="color: #0000ff">False</span></span></p><p><span style="font-size: 10px"><span style="color: #0000ff"></span></span></p><p><span style="font-size: 10px"><span style="color: #0000ff"></span></span><span style="font-size: 10px"><span style="color: #008000">'lblmessageerror.Visible = True</span></span></p><p><span style="font-size: 10px"><span style="color: #008000"></span></span></p><p><span style="font-size: 10px"><span style="color: #008000"></span></span><span style="font-size: 10px">lblmessageerror.Text = "No record found."</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px"></span><span style="font-size: 10px"><span style="color: #008000">'dgstaffinfo.Visible = False</span></span></p><p><span style="font-size: 10px"><span style="color: #008000"></span></span></p><p><span style="font-size: 10px"><span style="color: #008000"></span></span><span style="font-size: 10px"><span style="color: #008000">'End If</span></span></p><p><span style="font-size: 10px"><span style="color: #008000"></span></span></p><p><span style="font-size: 10px"><span style="color: #008000"></span></span><span style="font-size: 10px"><span style="color: #0000ff">End</span></span> <span style="font-size: 10px"><span style="color: #0000ff">Sub</span></span></p><p><span style="font-size: 10px"><span style="color: #0000ff"></span></span></p><p><span style="font-size: 10px"><span style="color: #0000ff"></span></span><span style="font-size: 10px"><span style="color: #0000ff">Private</span></span> <span style="font-size: 10px"><span style="color: #0000ff">Sub</span></span><span style="font-size: 10px"> btnsearch_Click(</span><span style="font-size: 10px"><span style="color: #0000ff">ByVal</span></span><span style="font-size: 10px"> sender </span><span style="font-size: 10px"><span style="color: #0000ff">As</span></span><span style="font-size: 10px"> System.Object, </span><span style="font-size: 10px"><span style="color: #0000ff">ByVal</span></span><span style="font-size: 10px"> e </span><span style="font-size: 10px"><span style="color: #0000ff">As</span></span><span style="font-size: 10px"> System.EventArgs) </span><span style="font-size: 10px"><span style="color: #0000ff">Handles</span></span><span style="font-size: 10px"> btnsearch.Click</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px"></span><span style="font-size: 10px"><span style="color: #0000ff">Me</span></span><span style="font-size: 10px">.searchstaffdetail()</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px"></span><span style="font-size: 10px"><span style="color: #0000ff">End</span></span> <span style="font-size: 10px"><span style="color: #0000ff">Sub</span></span></p><p><span style="font-size: 10px"><span style="color: #0000ff"></span></span></p><p><span style="font-size: 10px"><span style="color: #0000ff">End</span></span> <span style="font-size: 10px"><span style="color: #0000ff">Class</span></span></p><p></p><p><span style="font-size: 10px"><span style="color: #0000ff"><span style="color: black">Please anyone help me. </span></span></span></p><p><span style="font-size: 10px"><span style="color: #0000ff"></span></span></p></blockquote><p></p>
[QUOTE="jue, post: 6450, member: 2524"] hi.. i have problem here. How to search staff info base on staff name and staff no? staff info will out in datagrid. here is sample my coding. [size=2][/size][size=2][color=#0000ff]Private[/color][/size][size=2] [/size][size=2][color=#0000ff]Sub[/color][/size][size=2] searchstaffdetail() [/size][size=2][color=#0000ff]Dim[/color][/size][size=2] connString [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]New[/color][/size][size=2] ConnectionString() [/size][size=2][color=#0000ff]Dim[/color][/size][size=2] oleConn [/size][size=2][color=#0000ff]As[/color][/size][size=2] OleDb.OleDbConnection [/size][size=2][color=#0000ff]Dim[/color][/size][size=2] areaData [/size][size=2][color=#0000ff]As[/color][/size][size=2] OleDb.OleDbDataAdapter [/size][size=2][color=#0000ff]Dim[/color][/size][size=2] recSet [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]New[/color][/size][size=2] DataSet() [/size][size=2][color=#0000ff]Dim[/color][/size][size=2] strCon [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]String [/color][/size][size=2][/size][size=2][color=#0000ff]Dim[/color][/size][size=2] strSQL [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]String [/color][/size][size=2][/size][size=2][color=#0000ff]Dim[/color][/size][size=2] intCount [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]String [/color][/size][size=2]strCon = connString.connIHD strSQL = " select staff_no, name, dept, section " _ & " from PMO_staff_info order by name " [/size][size=2][color=#0000ff]If[/color][/size][size=2] Trim(txtstaffname.Text) <> "" [/size][size=2][color=#0000ff]Then [/color][/size][size=2]strSQL = strSQL & " and lower(name) like '%" & txtstaffname.Text.ToLower & "%'" [/size][size=2][color=#008000]''If Trim(txtstaffno.Text) <> "" Then [/color][/size][size=2][/size][size=2][color=#008000]'' strSQL = strSQL & " and staff_no = " & CInt(txtstaffno.Text) & "" [/color][/size][size=2][/size][size=2][color=#008000]'' 'ElseIf Trim(txtIC.Text) <> "" Then [/color][/size][size=2][/size][size=2][color=#008000]' strSQL = strSQL & " and staff_ic = " & CInt(txtIC.Text) & "" [/color][/size][size=2][/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]If [/color][/size][size=2]strSQL = strSQL & " order by name " areaData = [/size][size=2][color=#0000ff]New[/color][/size][size=2] OleDbDataAdapter(strSQL, strCon) areaData.Fill(recSet, "staffinfo") intCount = recSet.Tables(0).Rows.Count [/size][size=2][color=#008000]'If intCount > 0 Then [/color][/size][size=2]dgstaffinfo.DataSource = recSet dgstaffinfo.DataBind() dgstaffinfo.Visible = [/size][size=2][color=#0000ff]True [/color][/size][size=2]lblmessageerror.Visible = [/size][size=2][color=#0000ff]False [/color][/size][size=2][/size][size=2][color=#008000]'lblmessageerror.Visible = True [/color][/size][size=2]lblmessageerror.Text = "No record found." [/size][size=2][color=#008000]'dgstaffinfo.Visible = False [/color][/size][size=2][/size][size=2][color=#008000]'End If [/color][/size][size=2][/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]Sub [/color][/size][size=2][/size][size=2][color=#0000ff]Private[/color][/size][size=2] [/size][size=2][color=#0000ff]Sub[/color][/size][size=2] btnsearch_Click([/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] sender [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.Object, [/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] e [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.EventArgs) [/size][size=2][color=#0000ff]Handles[/color][/size][size=2] btnsearch.Click [/size][size=2][color=#0000ff]Me[/color][/size][size=2].searchstaffdetail() [/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]Sub End[/color][/size][size=2] [/size][size=2][color=#0000ff]Class[/color][/size] [size=2][color=#0000ff][/color][/size] [size=2][color=#0000ff][color=black]Please anyone help me. [/color] [/color][/size] [/QUOTE]
Insert quotes…
Verification
Post reply
Home
Forums
VB.NET
VB.NET General Discussion
How to search base on staff name and no?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top
Bottom