AugieDawgie
IS-IT--Management
Okay, I'm really new to this and am not sure how to get this to work, so here goes. I have a web form, User Administration. It contains a "search" button, which allows the user to search by first name or last name or both when clicked, depending on what the user has entered...it then populates the form with first name, last name, location, hardware & software for everyone that falls within the criteria. I've included the code below; however, I also have a databound location list box, which holds 42 of our stores. I can't figure out how to get a list of users at a specific location, if the location (no first or last name) is the only selected item prior to hitting the "search" button...I hope this makes sense and thanks in advance for any help you can give me.
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Fname = Trim(txtFnameAdd.Text)
Lname = Trim(txtLnameAdd.Text)
sql = "SELECT key_id, Fname, Lname, location, LEFT(Datemodified,11) as DateModified,"
sql = sql & "'<a href='"
sql = sql + "'Inventory Assign Hardware.aspx?ID='"
sql = sql & " + Cast(key_ID as Char) + "
sql = sql & "'''>Hardware Permissions"
sql = sql & "</a>' as Hardware,"
sql = sql & "'<a href='"
sql = sql + "'Inventory Assign Software.aspx?ID='"
sql = sql & " + Cast(key_ID as Char) + "
sql = sql & "'''>Software Permissions"
sql = sql & "</a>' as Software from Users "
If txtFnameAdd.Text <> "" And txtLnameAdd.Text = "" Then sql = sql & " WHERE Fname like '%' + '" & Fname & "' + '%'"
If txtLnameAdd.Text <> "" And txtFnameAdd.Text = "" Then sql = sql & " WHERE Lname like '%' + '" & Lname & "' + '%'"
sql = sql & BuildQuery()
daUsers = New System.Data.SqlClient.SqlDataAdapter(sql, SORCInventory)
daUsers.Fill(dsUser)
dgUsers.DataSource = dsUser
dgUsers.DataBind()
End Sub
Function GetLocations() As DataSet
Dim ddlDataSet As DataSet = New DataSet
Const strSQLDDL As String = _
"SELECT location FROM location ORDER BY location"
Dim myDataAdapter As SqlDataAdapter = New _
SqlDataAdapter(strSQLDDL, SORCInventory)
myDataAdapter.Fill(ddlDataSet, "Location")
Return ddlDataSet
End Function
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Fname = Trim(txtFnameAdd.Text)
Lname = Trim(txtLnameAdd.Text)
sql = "SELECT key_id, Fname, Lname, location, LEFT(Datemodified,11) as DateModified,"
sql = sql & "'<a href='"
sql = sql + "'Inventory Assign Hardware.aspx?ID='"
sql = sql & " + Cast(key_ID as Char) + "
sql = sql & "'''>Hardware Permissions"
sql = sql & "</a>' as Hardware,"
sql = sql & "'<a href='"
sql = sql + "'Inventory Assign Software.aspx?ID='"
sql = sql & " + Cast(key_ID as Char) + "
sql = sql & "'''>Software Permissions"
sql = sql & "</a>' as Software from Users "
If txtFnameAdd.Text <> "" And txtLnameAdd.Text = "" Then sql = sql & " WHERE Fname like '%' + '" & Fname & "' + '%'"
If txtLnameAdd.Text <> "" And txtFnameAdd.Text = "" Then sql = sql & " WHERE Lname like '%' + '" & Lname & "' + '%'"
sql = sql & BuildQuery()
daUsers = New System.Data.SqlClient.SqlDataAdapter(sql, SORCInventory)
daUsers.Fill(dsUser)
dgUsers.DataSource = dsUser
dgUsers.DataBind()
End Sub
Function GetLocations() As DataSet
Dim ddlDataSet As DataSet = New DataSet
Const strSQLDDL As String = _
"SELECT location FROM location ORDER BY location"
Dim myDataAdapter As SqlDataAdapter = New _
SqlDataAdapter(strSQLDDL, SORCInventory)
myDataAdapter.Fill(ddlDataSet, "Location")
Return ddlDataSet
End Function