Standard Web data problem (Access, DW CS3, Web form)

Excalibur1814

New member
Joined
Jun 16, 2010
Messages
1
Programming Experience
Beginner
Hello all

I have a vb.net web page that places data into an access database. If I leave one of the fields blank, (even though Access has a default value of '0' instead of null) when I click to view the results in another page, the page fails with an error. (.net 2.0.50727)


VB.NET:
System.InvalidOperationException: The provider could not determine the String value. For example, the row was just created, the default for the String column was not available, and the consumer had not yet set a new String value. 
at System.Data.OleDb.ColumnBinding.Value() 
at System.Data.OleDb.OleDbDataReader.GetValues(Object[] values) 
at System.Data.ProviderBase.DataReaderContainer.CommonLanguageSubsetDataReader.GetValues(Object[] values) 
at System.Data.ProviderBase.SchemaMapping.LoadDataRow() 
at System.Data.Common.DataAdapter.FillLoadDataRowChunk(SchemaMapping mapping, Int32 startRecord, Int32 maxRecords) 
at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue) 
at System.Data.Common.DataAdapter.Fill(DataSet dataSet, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords) 
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) 
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) 
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable) 
at DreamweaverCtrls.DataSet.DoInit()


IF I put any figure in the blank field, even if it's 0, the page functions and works. Baffling. So, the data input page really needs to check, 'if nothing has been entered, automatically append the database with 0.

Here's the page code: (Standard DreamW CS3 Record insertion wizard)

VB.NET:
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="utf-8" validateRequest="false" %>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicK eyToken=836f606ede05d46a,culture=neutral" %><MM:Insert
runat="server"
CommandText='<%# "INSERT INTO Energy_InputSheet1 (InAnnualElecCostID, InAnnualElecID, InAnnualGasCostID, InAnnualGasID, InAnnualOilCostID, InAnnualOilID, InAnnualSTurnID, 
InAnnualWaterCost, InAnnualWaterID, InAreProducedID, InCompanyAddID, InCompanyNameID, InContactPositionID, 
InCountryID, InEmailID, InEmployeeNoID, InFaxID, InLots, InProductionDaysID, InTelephoneID) 
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" %>'
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING_connITNoticeboardASP") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_DATABASETYPE_connITNoticeboard ASP") %>'
Expression='<%# Request.Form("MM_insert") = "form1" %>'
CreateDataSet="false"
SuccessURL='<%# "Energy_DataView1.aspx" %>'
FailureURL='<%# "Energy_Fail.aspx" %>'
Debug="true"
><Parameters>
<Parameter Name="@InAnnualElecCostID" Value='<%# IIf((Request.Form("InAnnualElecCostID") <> Nothing), Request.Form("InAnnualElecCostID"), "") %>' Type="Currency" /> 
<Parameter Name="@InAnnualElecID" Value='<%# IIf((Request.Form("InAnnualElecID") <> Nothing), Request.Form("InAnnualElecID"), "") %>' Type="Integer" /> 
<Parameter Name="@InAnnualGasCostID" Value='<%# IIf((Request.Form("InAnnualGasCostID") <> Nothing), Request.Form("InAnnualGasCostID"), "") %>' Type="Currency" /> 
<Parameter Name="@InAnnualGasID" Value='<%# IIf((Request.Form("InAnnualGasID") <> Nothing), Request.Form("InAnnualGasID"), "") %>' Type="Integer" /> 
<Parameter Name="@InAnnualOilCostID" Value='<%# IIf((Request.Form("InAnnualOilCostID") <> Nothing), Request.Form("InAnnualOilCostID"), "") %>' Type="Currency" /> 
<Parameter Name="@InAnnualOilID" Value='<%# IIf((Request.Form("InAnnualOilID") <> Nothing), Request.Form("InAnnualOilID"), "") %>' Type="Integer" /> 
<Parameter Name="@InAnnualSTurnID" Value='<%# IIf((Request.Form("InAnnualSTurnID") <> Nothing), Request.Form("InAnnualSTurnID"), "") %>' Type="Integer" /> 
<Parameter Name="@InAnnualWaterCost" Value='<%# IIf((Request.Form("InAnnualWaterCost") <> Nothing), Request.Form("InAnnualWaterCost"), "") %>' Type="Currency" /> 
<Parameter Name="@InAnnualWaterID" Value='<%# IIf((Request.Form("InAnnualWaterID") <> Nothing), Request.Form("InAnnualWaterID"), "") %>' Type="Integer" /> 
<Parameter Name="@InAreProducedID" Value='<%# IIf((Request.Form("InAreProducedID") <> Nothing), Request.Form("InAreProducedID"), "") %>' Type="Integer" /> 
<Parameter Name="@InCompanyAddID" Value='<%# IIf((Request.Form("InCompanyAddID") <> Nothing), Request.Form("InCompanyAddID"), "") %>' Type="WChar" /> 
<Parameter Name="@InCompanyNameID" Value='<%# IIf((Request.Form("InCompanyNameID") <> Nothing), Request.Form("InCompanyNameID"), "") %>' Type="WChar" /> 
<Parameter Name="@InContactPositionID" Value='<%# IIf((Request.Form("InContactPositionID") <> Nothing), Request.Form("InContactPositionID"), "") %>' Type="WChar" /> 
<Parameter Name="@InCountryID" Value='<%# IIf((Request.Form("InCountryID") <> Nothing), Request.Form("InCountryID"), "") %>' Type="WChar" /> 
<Parameter Name="@InEmailID" Value='<%# IIf((Request.Form("InEmailID") <> Nothing), Request.Form("InEmailID"), "") %>' Type="WChar" /> 
<Parameter Name="@InEmployeeNoID" Value='<%# IIf((Request.Form("InEmployeeNoID") <> Nothing), Request.Form("InEmployeeNoID"), "") %>' Type="Integer" /> 
<Parameter Name="@InFaxID" Value='<%# IIf((Request.Form("InFaxID") <> Nothing), Request.Form("InFaxID"), "") %>' Type="WChar" /> 
<Parameter Name="@InLots" Value='<%# IIf((Request.Form("InLots") <> Nothing), Request.Form("InLots"), "") %>' Type="Integer" /> 
<Parameter Name="@InProductionDaysID" Value='<%# IIf((Request.Form("InProductionDaysID") <> Nothing), Request.Form("InProductionDaysID"), "") %>' Type="Integer" /> 
<Parameter Name="@InTelephoneID" Value='<%# IIf((Request.Form("InTelephoneID") <> Nothing), Request.Form("InTelephoneID"), "") %>' Type="WChar" /> 
</Parameters>
</MM:Insert>
<MM:PageBind runat="server" PostBackBind="true" />
<script language="VB" runat="server">
' ================================================== =============================
' WWWeb Concepts ASP.NET Development Solutions TSMW: Standing Seam Metal Roofing, Awnings, Chimney Caps
' Copyright 2002. All Rights Reserved.
' ================================================== =============================
Sub Page_Load
If Not IsPostBack
'Validate intially to force *s to appear before the first round-trip
Validate()
End If
End Sub
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
.errortxt
{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #FF0000;
}
</style>
<script language="JavaScript" type="text/javascript">
<!--
function ClientOnChange() {
if (typeof(Page_Validators) == "undefined")
return;
document.all["lblOutput"].innerText = Page_IsValid ? "Thank you" : "Some of the required fields are empty";
}
// -->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SURFENERGY</title>
<style type="text/css">
<!--
.style2 {font-size: 10px;
color: #0000FF;
}
.style7 {font-size: 12px; font-weight: bold; font-style: italic; }
.style10 {font-size: 12px; font-weight: bold; }
-->
</style>
</head>
<body>
<div align="center">
<table width="865" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center"></div></td>
</tr>
<tr>
<td><div align="center">
<form method="post" name="form1" id="form1" runat="server">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="4"><img src="Media/SurfEnergyMain1.JPG" width="572" height="108" /></td>
</tr>
<tr>
<td width="47%"> </td>
<td width="17%"> </td>
<td width="32%"> </td>
<td width="4%"> </td>
</tr>
<tr>
<td colspan="4"><div align="center">
<p align="center"><strong>Advanced Tools for SURFace Finishing Processes to Optimise ENERGY Efficiency</strong></p>
<p align="justify"><strong>SURFENERGY energy advisor online tool Surface Finishing - Data entry </strong><br />
By supplying the following information you will be able to analyse the performance of your company compared to the benchmarks in the European Union. It will also demonstrate the potential cost saving which can be achieved if you were at the benchmark.</p>
</div></td>
</tr>
<tr>
<td> </td>
<td colspan="3"><asp:Label ID="lblOutput" name="lblOutput" Text="Please complete the specified information below" CssClass="errortxt" runat=server /> </td>
</tr>
<tr>
<td><div align="left">Company Name:</div></td>
<td colspan="2"><asp:TextBox ID="InCompanyNameID" TextMode="SingleLine" Columns="71" runat="server" Onchange="ClientOnChange();" /></td>
<td><asp:RequiredFieldValidator id="rfvInCompanyNameID" runat="server" ControlToValidate="InCompanyNameID" ErrorMessage="*" Display="Static"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td><div align="left">Contact Position:</div></td>
<td colspan="2"><asp:TextBox ID="InContactPositionID" TextMode="SingleLine" Columns="71" runat="server" Onchange="ClientOnChange();" /></td>
<td><asp:RequiredFieldValidator id="rfvInContactPositionID" runat="server" ControlToValidate="InContactPositionID" ErrorMessage="*" Display="Static"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td><div align="left">Company Address:</div></td>
<td colspan="2"><asp:TextBox ID="InCompanyAddID" TextMode="SingleLine" Columns="71" runat="server" Onchange="ClientOnChange();" /></td>
<td><asp:RequiredFieldValidator id="rfvInCompanyAddID" runat="server" ControlToValidate="InCompanyAddID" ErrorMessage="*" Display="Static"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td><div align="left">Country:</div></td>
<td colspan="2"><asp:TextBox ID="InCountryID" TextMode="SingleLine" Columns="71" runat="server" Onchange="ClientOnChange();" /></td>
<td><asp:RequiredFieldValidator ID="rfvInCountryID" runat="server" ControlToValidate="InCountryID" ErrorMessage="*" Display="Static"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td><div align="left">Telephone:</div></td>
<td colspan="2"><asp:TextBox ID="InTelephoneID" TextMode="SingleLine" Columns="71" runat="server" Onchange="ClientOnChange();" /></td>
<td><asp:RequiredFieldValidator id="rfvInTelephoneID" runat="server" ControlToValidate="InTelephoneID" ErrorMessage="*" Display="Static"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td><div align="left">Fax:</div></td>
<td colspan="2"><asp:TextBox ID="InFaxID" TextMode="SingleLine" Columns="71" runat="server" Onchange="ClientOnChange();" /></td>
<td><asp:RequiredFieldValidator id="rfvInFaxID" runat="server" ControlToValidate="InFaxID" ErrorMessage="*" Display="Static"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td><div align="left">e-mail:</div></td>
<td colspan="2"><asp:TextBox ID="InEmailID" TextMode="SingleLine" Columns="71" runat="server" Onchange="ClientOnChange();" /></td>
<td><asp:RequiredFieldValidator id="rfvInEmailID" runat="server" ControlToValidate="InEmailID" ErrorMessage="*" Display="Static"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td><div align="left"></div></td>
<td colspan="3"><span class="style7">Please enter basic rounded figures with no random characters or pence</span></td>
</tr>
<tr>
<td><div align="left">Number of Employees:</div></td>
<td><asp:TextBox ID="InEmployeeNoID" TextMode="SingleLine" Columns="11" runat="server" Onchange="ClientOnChange();" /></td>
<td> </td>
<td><asp:RequiredFieldValidator id="rfvInEmployeeNoID" runat="server" ControlToValidate="InEmployeeNoID" ErrorMessage="*" Display="Static"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td><div align="left">Production Days per Year:</div></td>
<td><asp:TextBox ID="InProductionDaysID" TextMode="SingleLine" Columns="11" runat="server" Onchange="ClientOnChange();" /></td>
<td><div align="left"><span class="style7">Example: 200</span></div></td>
<td><asp:RequiredFieldValidator id="rfvInProductionDaysID" runat="server" ControlToValidate="InProductionDaysID" ErrorMessage="*" Display="Static"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td><div align="left">Annual Sales / Turnover:</div></td>
<td><asp:TextBox ID="InAnnualSTurnID" TextMode="SingleLine" Columns="11" runat="server" Onchange="ClientOnChange();" /></td>
<td><div align="left"><span class="style7">Example: 1000000</span></div></td>
<td><asp:RequiredFieldValidator id="rfvInAnnualSTurnID" runat="server" ControlToValidate="InAnnualSTurnID" ErrorMessage="*" Display="Static"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td><div align="left">Area Produced, m²(estimate):</div></td>
<td><asp:TextBox ID="InAreProducedID" TextMode="SingleLine" Columns="11" runat="server" Onchange="ClientOnChange();" /></td>
<td><div align="left"><span class="style7">Example: 1000</span></div></td>
<td><asp:RequiredFieldValidator id="rfvInAreProducedID" runat="server" ControlToValidate="InAreProducedID" ErrorMessage="*" Display="Static"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td><div align="left">Total number of manufactured lots:</div></td>
<td><asp:TextBox ID="InLots" TextMode="SingleLine" Columns="11" runat="server" Onchange="ClientOnChange();" /></td>
<td><span class="style7">Example: 300</span></td>
<td><asp:RequiredFieldValidator id="rfvInLots" runat="server" ControlToValidate="InLots" ErrorMessage="*" Display="Static"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td> </td>
<td><div align="left"></div></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="4"><div align="center">will be estimated</div></td>
</tr>
<tr>
<td> </td>
<td><div align="left">Use, kWh</div></td>
<td><div align="left">Cost, €</div></td>
<td> </td>
</tr>
<tr>
<td><div align="left">Annual total electric energy consumption:</div></td>
<td><asp:TextBox ID="InAnnualElecID" TextMode="SingleLine" Columns="11" runat="server" /></td>
<td><asp:TextBox ID="InAnnualElecCostID" TextMode="SingleLine" Columns="7" runat="server" /></td>
<td> </td>
</tr>
<tr>
<td><div align="left">Annual total Natural Gas Consumption:</div></td>
<td><asp:TextBox ID="InAnnualGasID" TextMode="SingleLine" Columns="11" runat="server" /></td>
<td><asp:TextBox ID="InAnnualGasCostID" TextMode="SingleLine" Columns="7" runat="server" /></td>
<td> </td>
</tr>
<tr>
<td><div align="left">Annual total Oil Consumption:</div></td>
<td><asp:TextBox ID="InAnnualOilID" TextMode="SingleLine" Columns="11" runat="server" /></td>
<td><asp:TextBox ID="InAnnualOilCostID" TextMode="SingleLine" Columns="7" runat="server" /></td>
<td> </td>
</tr>
<tr>
<td><div align="left"></div></td>
<td><div align="left"></div></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><div align="left"></div></td>
<td><div align="left">Use, m³</div></td>
<td><div align="left">Cost, €</div></td>
<td> </td>
</tr>
<tr>
<td><div align="left">Annual total water consumption:</div></td>
<td><asp:TextBox ID="InAnnualWaterID" TextMode="SingleLine" Columns="11" runat="server" /></td>
<td><asp:TextBox ID="InAnnualWaterCost" TextMode="SingleLine" Columns="7" runat="server" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" value="Insert record" /></td>
<td> </td>
</tr>
<tr>
<td colspan="4"><div align="center">Company data </div></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><img src="Media/Banner1.JPG" width="321" height="58" />
<input type="hidden" name="MM_insert" value="form1" /></td>
<td colspan="3"><span class="style2">The sole etc</span></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<p> </p>
</form>
</div> <div align="center"></div></td>
</tr>
</table>
</div>
</body>
</html>
 
Back
Top