Hello,

I am a total noob to web development and am running into some problems. I am trying to search for a specific string, or records that contain a union of strings in a SQL Sever CE database using WebMatrix, and display the results. Ideally, I would like to have a webpage that contains forms where a user can input up to 3 different strings and click a submit button, and then have the results of the search displayed.

The other thing that I would like to do is have another webpage display records within a dynamic date range (i.e. today - 6 months) on load.

I am not even sure where to start with this. I am using the following code to display the columns that I want based on searching the database with a wild card.

@using WebMatrix.Data 
@{
var db= Database.Open("Orientation"); 
var sqlQ = "SELECT * FROM Orientation";
var data = db.Query(sqlQ);  
 }

<div class="content-box-main">
<ol>
@foreach(var row in data){
<li>
@row.FirstName, @row.LastName, @row.Email
</li>
}
</ol>

</div>

Okay, so I have made some progress. I have been able to pass variables from forms in another page to the SQL Query on the display page successfully, however, I can only get it to search for 1 variable and I need to be able to display records that have a union of all the variables. It also needs to be able to detect null values and replace them with wildcards. Here is my code so far. Everyone on here is so helpful. Thank you so much for the help with this.

@using WebMatrix.Data 


@{
var Keyword1 = Request.QueryString["firstname"];    //Retreives passed variable from the database search page for First Names
var Keyword2 = Request.QueryString["lastname"];    //Retreives passed variable from the database search page for First Names
var Keyword3 = Request.QueryString["company"];    //Retreives passed variable from the database search page for First Names
var db= Database.Open("Orientation"); 
var sqlQ = "SELECT * FROM Orientation WHERE FirstName=@0";
var data = db.Query(sqlQ, Keyword1);  
 }


<div class="content-box-main">

<ol>
@foreach(var row in data){
<li>
@row.LastName, @row.FirstName, @row.MiddleName, @row.Email, @row.Company, @row.Date
</li>
}
</ol><br>

</div>