I have a basic web form that inserts information into a ms sql database and I am trying to create a search page for it. I am running into the problem that after I insert the information into the web form page, submit it, and go to my search page the newly entered information doesn't show as part of the results. If I look in management studio I see the newly entered data is there, but for some reason I can't get it to show up on the gridview on my search page. This is the code behind my search page. What am I doing wrong?
Code:
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click 'Initializes a string with the necessary select statement for a unique search Dim searchString As String = "SELECT tblPersonalInformation.FirstName, tblPersonalInformation.LastName, tblAppointmentInformation.Status, tblAppointmentInformation.MembershipType, tblAppointmentInformation.StartDate FROM tblPersonalInformation, tblAppointmentInformation WHERE tblPersonalInformation.MemberID = tblAppointmentInformation.MemberID" 'This is the connection string for the IRB database dsSearch.ConnectionString = "Data Source=MEDRESEARCHSQL;Initial Catalog=IRB;User ID=wbrands2;Password=pizza123" gvsearch.Visible = True If (txtLastName.Text <> "") Then 'Inserts the where statement for last name 'based on whether or not it is the first part of the where clause or building onto it searchString = searchString + " AND [LastName] LIKE '" + txtLastName.Text + "' + '%'" End If 'Determines whether a background is selected to search on If (ddlStatus.Text <> "Choose One:") Then 'Inserts the where statement for background searchString = searchString + " AND [Status] = '" + ddlStatus.Text + "'" End If 'determines whether a affiliation is selected to search on If (ddlAffiliation.Text <> "Choose One:") Then 'Inserts the where statement for Affiliation searchString = searchString + " AND [Affiliation] = '" + ddlAffiliation.Text + "'" End If 'Determines whether a membership status is selected to search on If (ddlMembershipType.Text <> "Choose One:") Then 'Inserts the where statement for membership status searchString = searchString + " AND [MembershipType] = '" + ddlMembershipType.Text + "'" End If 'Used in testing to see what the full SQL statement looks like lblSearchString.Text = searchString 'This sets the select command equal to the search string dsSearch.SelectCommand = searchString End Sub
Comment