I am trying to figure out what I have done wrong with my code (lies below). I have tried several different approaches and searched for several approaches online, but I cannot seem to find out why this code will not add entries to my database. I use WebMatrix (cshtml for web interface, using C#) with a SQL Server Compact database. I am very new to using a web interface with a database. Any help is much appreciated!
@{
var errorMessage = "";
var POIName = "";
var DateLastModified = "";
var Height = "";
var Weight = "";
var HairColor = "";
var EyeColor = "";
var DOB = "";
var SS = "";
var insertQueryString = "";
if(IsPost)
{
POIName=Request.Form["POIName"];
DateLastModified=Request.Form["DateLastModified"];
Height=Request.Form["Height"];
Weight=Request.Form["Weight"];
HairColor=Request.Form["HairColor"];
EyeColor=Request.Form["EyeColor"];
DOB=Request.Form["DOB"];
SS=Request.Form["SS"];
insertQueryString = "INSERT INTO POITable " +
"(POIName, DateLastModified, Height, Weight, HairColor, EyeColor, DOB, SS) " +
"VALUES (@0, @1, @2, @3, @4, @5, @6, @7)";
var db = Database.Open("PersonsOfInterest");
db.Execute(insertQueryString, POIName, DateLastModified, Height, Weight, HairColor, EyeColor, DOB, SS);
Response.Redirect("~/");
}
}
@RenderPage("~/Shared/HeaderLayout.cshtml")
<div id="FormHolder">
<form action="" method="post">
<table class="formTable">
<tr>
<td class="upperTable">
<span class="oneLine"><label class="upperLabel" for="POIName">POI Name: </label><input type="text" id="POIName" name="POIName" maxlength="50" value=""/></span></br>
<span class="oneLine"><label class="upperLabel" for="DateLastModified">Date Last Modified: </label><input type="text" id="DateLastModified" name="DateLastModified" maxlength="10" value="" /></span></br>
<span class="oneLine"><label class="upperLabel" for="Height">Height: </label><input type="text" id="Height" name="Height" maxlength="5" value="" /></span></br>
<span class="oneLine"><label class="upperLabel" for="Weight">Weight: </label><input type="text" id="Weight" name="Weight" value="" /></span></br>
<span class="oneLine"><label class="upperLabel" for="HairColor">Hair Color: </label><input type="text" id="HairColor" name="EyeColor" maxlength="10" value="" /></span></br>
<span class="oneLine"><label class="upperLabel" for="EyeColor">Eye Color: </label><input type="text" id="EyeColor" name="EyeColor" maxlength="10" value="" /></span></br>
<span class="oneLine"><label class="upperLabel" for="DOB">DOB: </label><input type="text" id="DOB" name="DOB" maxlength="10" value="" /></span></br>
<span class="oneLine"><label class="upperLabel" for="SS">SS#: </label><input type="text" id="SS" name="SS" maxlength="11" value="" /></span></br>
<span class="oneLine"><label class="upperLabel" for="DL">DL#: </label><input type="text" id="DL" name="DL" maxlength="10" value="" /></span></br>
<span class="oneLine"><label class="upperLabel" for="DOC">DOC#: </label><input type="text" id="DOC" name="DOC" maxlength="10" value="" /></span></br>
<span class="oneLine"><label class="upperLabel" for="VehicleTag">Vehicle Tag #: </label><input type="text" id="VehicleTag" name="VehicleTag" maxlength="10" value="" /></span></br>
<span class="oneLine"><label class="upperLabel" for="FBI">FBI#: </label><input type="text" id="FBI" name="FBI" maxlength="10" value="" /></span></br>
<span class="oneLine"><label class="upperLabel" for="Officer">Officer: </label><input type="text" id="Officer" name="Officer" maxlength="50" value="" /></span></br>
<span class="threeLine" style="padding-left: 2px;"><label class="upperLabel" for="AdditionalDescriptors">Additional</br>Descriptors: </label><textarea cols="16" rows="5" id="AdditionalDescriptors" name="AdditionalDescriptors" maxlength="500"></textarea></span></br>
<span class="oneLine"><label class="upperLabel" for="HomePhone">Home Phone</br>Number: </label><input type="text" id="HomePhone" name="HomePhone" maxlength="14" value="" /></span></br>
</td>
<td class="upperTable">
<span class="twoLine" style="padding-left: 2px;"><label class="upperLabel" for="Aliases">Aliases: </label><textarea cols="16" rows="3" id="Aliases" name="Aliases" maxlength="500"></textarea></span></br>
<span class="threeLine" style="padding-left: 2px;"><label class="upperLabel" for="SourceOfInformation">Source of</br>Information: </label><textarea cols="16" rows="5" id="SourceOfInformation" name="SourceOfInformation" maxlength="500"></textarea></span></br>
<span class="threeLine" style="padding-left: 2px;"><label class="upperLabel" for="Address">Address: </label><textarea cols="16" rows="5" id="Address" name="Address" maxlength="500"></textarea></span></br>
<span class="threeLine" style="padding-left: 2px;"><label class="upperLabel" for="AddressInformation">Additional</br>Address</br>Information: </label><textarea cols="16" rows="5" id="AddressInformation" name="AddressInformation" maxlength="500"></textarea></span></br>
<span class="twoLine" style="padding-left: 2px;"><label class="upperLabel" for="KnownAssociates">Known</br>Associates: </label><textarea cols="16" rows="3" id="KnownAssociates" name="KnownAssociates" maxlength="500"></textarea></span></br>
<span class="threeLine" style="padding-left: 2px;"><label class="upperLabel" for="VehicleDescription">Vehicle</br>Description: </label><textarea cols="16" rows="5" id="VehicleDescription" name="VehicleDescription" maxlength="500"></textarea></span></br>
<span class="oneLine"><label class="upperLabel" for="CellPhone">Cell Phone</br>Number: </label><input type="text" id="CellPhone" name="CellPhone" maxlength="14" value="" /></span></br>
</td>
<td class="upperTable">
<span class="mugshot"><label class="upperLabel" for="Mugshot">Mugshot: </label><input type="text" id="Mugshot" name="Mugshot" value="" /></span></br>
<span class="threeLine" style="padding-left: 2px;"><label class="upperLabel" for="Comments">Comments: </label><textarea cols="16" rows="5" id="Comments" name="Comments" maxlength="500"></textarea></span></br>
<span class="oneLine"><label class="upperLabel" for="WorkPhone">Work Phone</br>Number: </label><input type="text" id="WorkPhone" name="WorkPhone" maxlength="14" value="" /></span></br>
</td>
</tr>
</table></br></br>
<span style="font-size: 3em;">________________________________________________</span></br></br>
<span class="oneLine" style="padding-left: 450px;"><label for="WeightedAggregate">Weighted Aggregate: </label><input type="text" id="WeightedAggregate" name="WeightedAggregate" readonly="true" value="0" /></span></br></br>
<table class="formTable">
<tr>
<td>
<ul style="margin-left: -60px;">
<li><span class="oneLineBottom" style="color: #f00"><input type="checkbox" id="WAM1" name="WAM" value="1"/><label for="WAM1"> Admits Membership</label></span></li>
<li><span class="oneLineBottom" style="color: #f00"><input type="checkbox" id="WAM2" name="WAM" value="2"/><label for="WAM2"> Admits Association</label></span></li>
<li><span class="oneLineBottom"><input type="checkbox" id="WAM3" name="WAM" value="3"/><label for="WAM3"> Admits Set Affiliation</label></span></li>
<li><span class="oneLineBottom" style="color: #f00"><input type="checkbox" id="WAM4" name="WAM" value="4"/><label for="WAM4"> Gang Tattoos or Branded</label></span></li>
<li><span class="oneLineBottom"><input type="checkbox" id="WAM5" name="WAM" value="5"/><label for="WAM5"> Gang Clothing or Colors</label></span></li>
</ul>
</td>
<td>
<ul style="margin-left: -215px;">
<li><span class="oneLineBottom"><input type="checkbox" id="WAM6" name="WAM" value="6"/><label for="WAM6"> Hand Signs</label></span></li>
<li><span class="oneLineBottom"><input type="checkbox" id="WAM7" name="WAM" value="7"/><label for="WAM7"> Gang Paraphernalia</label></span></li>
<li><span class="oneLineBottom"><input type="checkbox" id="WAM8" name="WAM" value="8"/><label for="WAM8"> Consistently Observed/FIR's</label></span></li>
<li><span class="oneLineBottom"><input type="checkbox" id="WAM9" name="WAM" value="9"/><label for="WAM9"> Observed with Known Members</label></span></li>
<li><span class="oneLineBottom"><input type="checkbox" id="WAM10" name="WAM" value="10"/><label for="WAM10"> Gang Involved Incidents</label></span></li>
</ul>
</td>
<td>
<ul style="margin-left: -175px;">
<li><span class="oneLineBottom" style="color: #f00"><input type="checkbox" id="WAM11" name="WAM" value="11"/><label for="WAM11"> Identified by Member as a Gang Member</label></span></li>
<li><span class="oneLineBottom" style="color: #f00"><input type="checkbox" id="WAM12" name="WAM" value="12"/><label for="WAM12"> Identified as a Gang Member by Two or More Sources</label></span></li>
<li><span class="oneLineBottom"><input type="checkbox" id="WAM13" name="WAM" value="13"/><label for="WAM13"> In Photo with Confirmed Gang Member</label></span></li>
<li><span class="oneLineBottom"><input type="checkbox" id="WAM14" name="WAM" value="14"/><label for="WAM14"> Named as a Gang Member in Gang Correspondence</label></span></li>
<li><span class="oneLineBottom"><input type="checkbox" id="WAM15" name="WAM" value="15"/><label for="WAM15"> Targeted by Rivals</label></span></li>
</ul>
</td>
<td>
<ul style="margin-left: -40px;">
<li><span class="oneLineBottom"><input type="checkbox" id="WAM16" name="WAM" value="16"/><label for="WAM16"> FIR while Involved in Gang Activity</label></span></li>
<li><span class="oneLineBottom"><input type="checkbox" id="WAM17" name="WAM" value="17"/><label for="WAM17"> Date Arrested for Violent or Weapon Offense</label></span></li>
<li><span class="oneLineBottom"><input type="checkbox" id="WAM18" name="WAM" value="18"/><label for="WAM18"> Felony Criminal History</label></span></li>
<li><span class="oneLineBottom"><input type="checkbox" id="WAM19" name="WAM" value="19"/><label for="WAM19"> Confirmed by Outside Agency</label></span></li>
<li><span class="oneLineBottom"><input type="checkbox" id="WAM20" name="WAM" value="20"/><label for="WAM20"> On Roster Produced by Gang Associates</label></span></li>
</ul>
</td>
</tr>
</table></br></br>
<table class="formTable">
<tr>
<td style="vertical-align: middle; color: #0094ff; padding-left: 20px; padding-right: 70px; width: 500px;">
<span>An individual should be considered for confirmation as a criminal street gang
member when the individual meets the weighted aggregate of at least 20
points and is associated with at least one of the above criteria labeled in red.</span>
</td>
<td style="text-align: center; padding-left: 70px;">
<span style="float: left; height: 120px;"><label>Summarized Incidents Supporting Gang Member Criteria: </label></br>
<textarea style="width: 500px; height: 90px;" id="SummarizedIncidents" name="SummarizedIncidents" maxlength="1000"></textarea></span></br>
</td>
</tr>
</table>
<span style="font-size: 3em;">________________________________________________</span></br></br>
<button type="button" class="btn" onclick="location.href='/IntroPage.cshtml'">Dismiss Entry</button>
<button type="button" class="btn" onclick="location.href=''">Save Entry</button>
</form>
</div>
@RenderPage("~/Shared/FooterLayout.cshtml")
I don't think you will need the code from the rendered pages, but if needed I will provide them (they are just links, head section, and some common closing tags for making a future footer to the page).
When I submit the form, nothing really appears to happen (except it reloads the page), but there are no added entries in the database. Again, you'll have to forgive me, I'm new, so if I am missing something ultra obvious, I apologize, but I simply haven't been able to find a solution. Thanks!