Subject: System.Data.OleDb.OleDbException: No value given f
Posted By: tjgrindsted Post Date: 1/24/2007 6:25:00 AM
I get this error when running my site if i changes the code to formview it's works but i need it to be showing in gridview. and if i changes to <connectionStrings> ConnStrAccess its works in Formview but not in Gridview, can someone pleas help me.

Error:
Exception Details: System.Data.OleDb.OleDbException: No value given for one or more required parameters.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace:


[OleDbException (0x80040e10): No value given for one or more required parameters.]
   System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +267
   System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +192
   System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +48
   System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +106
   System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) +111
   System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +4
   System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +141
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +137
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +83
   System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1770
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +17
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
   System.Web.UI.WebControls.GridView.DataBind() +4
   System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
   System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +69
   System.Web.UI.Control.EnsureChildControls() +87
   System.Web.UI.Control.PreRenderRecursiveInternal() +41
   System.Web.UI.Control.PreRenderRecursiveInternal() +161
   System.Web.UI.Control.PreRenderRecursiveInternal() +161
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360

 
Code:
Default.aspx

<%@ Page Language="VB"%>
<!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 runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="CM_form" runat="server">
    <div>
        &nbsp;
<asp:GridView AutoGenerateColumns="true" DataKeyNames="SiteMainID,SiteMainIdentity,SiteMainText" DataSourceID="CMSqlDataSource" ID="GridView1" runat="server">

            <Columns>

                <asp:BoundField DataField="SiteMainID" HeaderText="ID" SortExpression="SiteMainID"></asp:BoundField>

                <asp:BoundField DataField="SiteMainIdentity" HeaderText="Identity" SortExpression="SiteMainIdentity"></asp:BoundField>

                <asp:BoundField DataField="SiteMainText" HeaderText="Text" SortExpression="SiteMainText">

                </asp:BoundField>

            </Columns>

        </asp:GridView>
        <asp:SqlDataSource ID="CMSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:CMConnectionString %>" SelectCommandType="Text"
            ProviderName="<%$ ConnectionStrings:CMConnectionString.ProviderName %>" SelectCommand="SELECT [SiteMainID], [SiteMainIdentity], [SiteMainText] FROM [MainSiteText] ORDER BY [SiteMainID]">
        </asp:SqlDataSource>
    </div>

    </form>
</body>
</html>


web.config

<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    <connectionStrings>
  <add name="ConnStrAccess" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\web\localuser\mydomain.dk\database\DSNbase.mdb"
   providerName="System.Data.OleDb" />
  <add name="CMConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\web\localuser\mydomain.dk\database\DSNbase.mdb"
   providerName="System.Data.OleDb" />
 </connectionStrings>
    <system.web>
        <pages>
            <namespaces>
                <clear/>
                <add namespace="System"/>
                <add namespace="System.Collections"/>
                <add namespace="System.Collections.Specialized"/>
                <add namespace="System.Configuration"/>
                <add namespace="System.Text"/>
                <add namespace="System.Text.RegularExpressions"/>
                <add namespace="System.Web"/>
                <add namespace="System.Web.Caching"/>
                <add namespace="System.Web.SessionState"/>
                <add namespace="System.Web.Security"/>
                <add namespace="System.Web.Profile"/>
                <add namespace="System.Web.UI"/>
                <add namespace="System.Web.UI.WebControls"/>
                <add namespace="System.Web.UI.WebControls.WebParts"/>
                <add namespace="System.Web.UI.HtmlControls"/>
                <add namespace="System.Web.UI.WebControls.Calendar"/>
                <add namespace="System.Data"/>
                <add namespace="System.Data.OleDb"/>
                <add namespace="System.IO"/>
            </namespaces>
        </pages>
        <authentication mode="Windows"/>
        <!--
            The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->
        <customErrors mode="Off"/>
    </system.web>
</configuration>



Go to topic 55299

Return to index page 54
Return to index page 53
Return to index page 52
Return to index page 51
Return to index page 50
Return to index page 49
Return to index page 48
Return to index page 47
Return to index page 46
Return to index page 45