MS Access / VB.net .aspx pages & data
excalibur1814
Member Posts: 82 ■■□□□□□□□□
in Off-Topic
Hello again
I thought that I'd solved the problem but not so.
Ok. I have a vb.net web page that places data into an access database. If I leave one of the field 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.
"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. etc etc"
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:
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="utf-8" validateRequest="false" %>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=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.AppSettings("MM_CONNECTION_STRING_connITNoticeboardASP") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_connITNoticeboardASP") %>'
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">
'
<snip>
I thought that I'd solved the problem but not so.
Ok. I have a vb.net web page that places data into an access database. If I leave one of the field 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.
"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. etc etc"
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:
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="utf-8" validateRequest="false" %>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=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.AppSettings("MM_CONNECTION_STRING_connITNoticeboardASP") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_connITNoticeboardASP") %>'
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">
'
<snip>
Mooooo
Comments
-
excalibur1814 Member Posts: 82 ■■□□□□□□□□Solved.
Add a zero<Parameter Name="@InAnnualElecID" Value='<%# IIf((Request.Form("InAnnualElecID") <> Nothing), Request.Form("InAnnualElecID"), "0") %>' Type="Integer" />
Original<Parameter Name="@InAnnualElecID" Value='<%# IIf((Request.Form("InAnnualElecID") <> Nothing), Request.Form("InAnnualElecID"), "") %>' Type="Integer" />
Mooooo