473,325 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Creating a Search in asp.net

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?

Expand|Select|Wrap|Line Numbers
  1. Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
  2.         'Initializes a string with the necessary select statement for a unique search
  3.         Dim searchString As String = "SELECT tblPersonalInformation.FirstName, tblPersonalInformation.LastName, tblAppointmentInformation.Status, tblAppointmentInformation.MembershipType, tblAppointmentInformation.StartDate FROM tblPersonalInformation, tblAppointmentInformation WHERE tblPersonalInformation.MemberID = tblAppointmentInformation.MemberID"
  4.  
  5.         'This is the connection string for the IRB database
  6.         dsSearch.ConnectionString = "Data Source=MEDRESEARCHSQL;Initial Catalog=IRB;User ID=wbrands2;Password=pizza123"
  7.         gvsearch.Visible = True
  8.         If (txtLastName.Text <> "") Then
  9.             'Inserts the where statement for last name
  10.             'based on whether or not it is the first part of the where clause or building onto it
  11.             searchString = searchString + " AND [LastName] LIKE '" + txtLastName.Text + "' + '%'"
  12.         End If
  13.  
  14.         'Determines whether a background is selected to search on
  15.         If (ddlStatus.Text <> "Choose One:") Then
  16.             'Inserts the where statement for background 
  17.             searchString = searchString + " AND [Status] = '" + ddlStatus.Text + "'"
  18.         End If
  19.  
  20.         'determines whether a affiliation is selected to search on
  21.         If (ddlAffiliation.Text <> "Choose One:") Then
  22.             'Inserts the where statement for Affiliation
  23.             searchString = searchString + " AND [Affiliation] = '" + ddlAffiliation.Text + "'"
  24.         End If
  25.  
  26.         'Determines whether a membership status is selected to search on
  27.         If (ddlMembershipType.Text <> "Choose One:") Then
  28.             'Inserts the where statement for membership status 
  29.             searchString = searchString + " AND [MembershipType] = '" + ddlMembershipType.Text + "'"
  30.         End If
  31.  
  32.         'Used in testing to see what the full SQL statement looks like
  33.         lblSearchString.Text = searchString
  34.         'This sets the select command equal to the search string 
  35.         dsSearch.SelectCommand = searchString
  36.     End Sub
Aug 1 '08 #1
1 1240
DrBunchman
979 Expert 512MB
Hi wbrands2

Welcome to Bytes.com! I hope you find the site useful.

You've posted your question in the ASP Forum which is for Classic ASP only - I've moved it for you but in future please post all ASP.NET questions in the .NET Forum.

Also please use the # button to wrap your code in CODE tags - it makes your posts much easier to read.

Good luck finding a solution to your problem.

Dr B
MODERATOR
Aug 4 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: gonzalo briceno | last post by:
I have been using phplib for a while and I really like the framework except for form creation. Maybe it is me but I in my opinion there isn't a good way to create forms or should I say, everything...
2
by: Iain Miller | last post by:
Now this shouldn't be hard but I've been struggling on the best way as to how to do this one for a day or 3 so I thought I'd ask the assembled company..... I'm writing an application that tracks...
2
by: alternativa | last post by:
Hi, I have a following problem: I need to create a set of classes which together can make a data base. Say we have: class Student { string sname; int snumber; Student *snextptr; ...
3
by: wherez73 | last post by:
Hi, IE7 has a search bar from which you can search on the internet. It is also possible to add a site to the list of sources for this bar. The only disadvantage of this is that it pass the full...
2
by: richard_b_lloyd | last post by:
I've noticed that there are tons of tutories for creating search engines / search pages using vb.net. What all of these tutorials don't cover is how to parse the search text the user has enetered...
3
by: Redbeard | last post by:
Hi All this is my first time post, be gentle. I am looking at creating a keyword search that searches multiple fields in a Form and then filters records that match the keyword. The Form...
3
by: teephish | last post by:
Hello, I'm currently in the process of creating a small access database and I'm having some problems with creating a customized search. I would like the user to be able to search a record by last...
2
by: slizorn | last post by:
hi guys, i need to make a tree traversal algorithm that would help me search the tree.. creating a method to search a tree to find the position of node and to return its pointer value basically i...
1
by: DaveD | last post by:
Let's say I have a collection ("items") of objects that each have a "string Name" property. I understand I can create a loop like this: foreach (string name in names) { var item = (from x in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.