So i have this method, that accepts data inputs of various types from a web form...now some of them (if not all) can be left empty...and thus insert nothing. now my coding is not allowing it to accept these empty strings, any ideas?
This is the coding i am using at the moment;
protected void Submit_OnClick(object sender, EventArgs e)<br />
{<br />
try<br />
{<br />
vesselLicense.InsertVslLic1(Convert.ToDateTime(txtRegistrationDate.Text), Convert.ToInt32(txtMartimeRegistrationNumber.Text), txtVesselName.Text, <br />
Convert.ToInt32(ddlVesselCategory.SelectedValue),rblOperativeStatus.SelectedValue, Convert.ToInt32(ddlBasePort.SelectedValue), <br />
txtRemarks.Text, txtPreviousAuthorisation.Text, Convert.ToDouble(txtOverallLenght.Text),Convert.ToDouble(txtWidth.Text), <br />
Convert.ToDouble(txtHeight.Text), txtConstructionPlace.Text, txtCountry.Text, Convert.ToInt32(txtContructionYear.Text), txtShipyard.Text, <br />
txtHullMaterial.Text,txtStructuralRemarks.Text);<br />
<br />
lblMessage.Text = "Data Input Successful";<br />
<br />
Response.Redirect("VesselLicense_Page2.aspx", false);<br />
}<br />
catch (Exception ex)<br />
{<br />
lblMessage.Text = ex.Message;<br />
}
This is the InsertVslLic1() Method used to input the data in the database (SQL Server 200)
public void InsertVslLic1(DateTime regDate, int martimeRegNo, string vesselName, int vesselCategory, string operativeStatus, int basePort, string vesselRemarks,<br />
string previousAuthorisation, double lenght, double width, double height, string constructionPlace, string country, int constructionYear, string shipyard, string hullMaterial,<br />
string structuralRemarks)<br />
{<br />
try<br />
{<br />
DBConnection db = new DBConnection();<br />
db.OpenConnection();<br />
<br />
string _sqlString = ("EXECUTE spA_FSH_InsertVslLic1 @RegistrationDate = '" + regDate<br />
+ "', @MartimeRegNum ='" + martimeRegNo<br />
+ "', @FishingVesselName ='" + vesselName<br />
+ "', @FishingVesselType ='" + vesselCategory<br />
+ "', @OperationalStatus ='" + operativeStatus<br />
+ "', @FishingVesselBasePort ='" + basePort<br />
+ "', @FishingVesselRemarks ='" + vesselRemarks<br />
+ "', @PreviousAuthorisation ='" + previousAuthorisation<br />
+ "', @FishingVesselLenght ='" + lenght<br />
+ "', @FishingVesselWidth ='" + width<br />
+ "', @FishingVesselHeight ='" + height<br />
+ "', @ConstructionPlace ='" + constructionPlace<br />
+ "', @ConstructionCountry ='" + country<br />
+ "', @ConstructionYear ='" + constructionYear<br />
+ "', @ConstructionShipyard ='" + shipyard<br />
+ "', @ConstructionHullMaterial ='" + hullMaterial<br />
+ "', @ConstructionRemarks ='" + structuralRemarks<br />
+ "', @HomePortID ='" + basePort+ "'");<br />
db.RunSQLQuery(_sqlString);<br />
}<br />
catch (Exception ex)<br />
{<br />
throw ex;<br />
}
Any ideas on how i can fix this? thank you
|