0

I am trying to run an Asp.NET page with SQLite database as datasource for a Repeater. The Sqlite data source and the dll files required to run it work fine when I use them in an Ado.NET program, but show the following error in the webpage(aspx) at runtime:

System.Web.HttpException
Property enroll not found in System.Char
Description: HTTP 500.Error processing request.

Details: Error processing request.

Stack Trace:

at System.Web.UI.DataBinder.GetPropertyValue (System.Object container, System.String propName) [0x00062] in <6bd7a846f9aa4f0bae143ad0f36ee3bd>:0 
at System.Web.UI.DataBinder.Eval (System.Object container, System.String expression) [0x0005d] in <6bd7a846f9aa4f0bae143ad0f36ee3bd>:0 
at System.Web.UI.TemplateControl.Eval (System.String expression) [0x0000b] in <6bd7a846f9aa4f0bae143ad0f36ee3bd>:0 
at ASP.about_aspx.__DataBind__bctrl_4 (System.Object sender, System.EventArgs e) [0x00013] in <cda3370d68f04a978aeb173db70786cf>:0 
at System.Web.UI.Control.OnDataBinding (System.EventArgs e) [0x00023] in <6bd7a846f9aa4f0bae143ad0f36ee3bd>:0 
at System.Web.UI.Control.DataBind (System.Boolean raiseOnDataBinding) [0x00031] in <6bd7a846f9aa4f0bae143ad0f36ee3bd>:0 
at System.Web.UI.Control.DataBind () [0x00000] in <6bd7a846f9aa4f0bae143ad0f36ee3bd>:0 
at System.Web.UI.Control.DataBindChildren () [0x00030] in <6bd7a846f9aa4f0bae143ad0f36ee3bd>:0 
at System.Web.UI.Control.DataBind (System.Boolean raiseOnDataBinding) [0x0003c] in <6bd7a846f9aa4f0bae143ad0f36ee3bd>:0 
at System.Web.UI.Control.DataBind () [0x00000] in <6bd7a846f9aa4f0bae143ad0f36ee3bd>:0 
at System.Web.UI.WebControls.Repeater.DoItem (System.Int32 i, System.Web.UI.WebControls.ListItemType t, System.Object d, System.Boolean databind) [0x0004a] in <6bd7a846f9aa4f0bae143ad0f36ee3bd>:0 
at System.Web.UI.WebControls.Repeater.CreateControlHierarchy (System.Boolean useDataSource) [0x00078] in <6bd7a846f9aa4f0bae143ad0f36ee3bd>:0 
at System.Web.UI.WebControls.Repeater.OnDataBinding (System.EventArgs e) [0x00022] in <6bd7a846f9aa4f0bae143ad0f36ee3bd>:0 
at System.Web.UI.WebControls.Repeater.DataBind () [0x00000] in <6bd7a846f9aa4f0bae143ad0f36ee3bd>:0 
at WebApp.About.Page_Load (System.Object sender, System.EventArgs e) [0x00011] in <cf8ee0554811421f8f91feab1903c901>:0 
at System.Web.UI.Control.OnLoad (System.EventArgs e) [0x00023] in <6bd7a846f9aa4f0bae143ad0f36ee3bd>:0 
at System.Web.UI.Control.LoadRecursive () [0x00028] in <6bd7a846f9aa4f0bae143ad0f36ee3bd>:0 
at System.Web.UI.Page.ProcessLoad () [0x0004a] in <6bd7a846f9aa4f0bae143ad0f36ee3bd>:0 
at System.Web.UI.Page.ProcessPostData () [0x00047] in <6bd7a846f9aa4f0bae143ad0f36ee3bd>:0 
at System.Web.UI.Page.InternalProcessRequest () [0x001a1] in <6bd7a846f9aa4f0bae143ad0f36ee3bd>:0 
at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context) [0x0005f] in <6bd7a846f9aa4f0bae143ad0f36ee3bd>:0 

The server I am using is XSP on ubuntu 18.04. I have downloaded the SQLite assemblies from : https://sourceforge.net/projects/sqlite-dotnet2/

When this error occurs, the following line is printed at the console:

Unknown type: System.Object value: SqlDataSource1

Here is my ASPX file:

    <%@ Page Title="About" Language="C#" AutoEventWireup="true" src="About.aspx.cs" Inherits="WebApp.About"%>

<!DOCTYPE html>

<html lang="en">
<head runat="server">

</head>
<body>
    <p>Hello</p>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="Data Source=sample.db;Pooling=True;Max Pool Size=100;"
    SelectCommand="SELECT [name],[enroll] FROM student;"></asp:SqlDataSource>

    <table>
        <asp:Repeater runat="server" ID="Repeater1" DataSource="SqlDataSource1">
            <HeaderTemplate>
                <tr>
                    <td>Enroll</td>
                    <td>Name</td>
                </tr>
            </HeaderTemplate>
            <ItemTemplate>
                <tr>
                    <td><%# Eval("enroll")%></td>
                    <td><%# Eval("name")%></td>
                </tr>
            </ItemTemplate>
        </asp:Repeater>
    </table>

</body>
</html>

And here is the related C# file:

    using System;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data.SQLite;
    using System.IO;

    namespace WebApp
    {
      public class About : Page
      {
        protected void Page_Load(object sender, EventArgs e)
        {
          Repeater repeater = FindControl("Repeater1") as Repeater ;
          // Response.Write(Directory.GetCurrentDirectory());
          repeater.DataBind();
        }

      }
    }

Am I not using the right way of binding the data source ? Or is the database file not referenced properly ? The database file is in the same directory as the .aspx and .cs files and the assemblies are in a folder called "bin". I've tested by using invalid assembly names that the assemblies for SQLite are being used at compile time.

  • I dont think you need any databind code inside `Page_Load` event handler as you have already specified the `DataSource="SqlDataSource1"` for repeater in aspx markup – Mohsin Mehmood Mar 24 '19 at 05:15
  • When I don't include that `DataBind` line, no data is read from the database and repeater produces no output. Even after adding the `DataBind`, I don't get any output from the database, but it shows this error stack trace, hence I assumed that without the `DataBind` line, it is not attempting to get any data. – Shivang Gangadia Mar 24 '19 at 05:19
  • Here is a suggestion: Create `App_Data` folder in your website and then move the sample.db file inside `App_Data` folder. Then update the data source in connection string like `Data Source=|DataDirectory|\sample.db;` – Mohsin Mehmood Mar 24 '19 at 06:04
  • No effect. Same error – Shivang Gangadia Mar 24 '19 at 07:20
  • Have you tried without databind code in page load? – Mohsin Mehmood Mar 24 '19 at 12:02
  • Yes, as mentioned in the second comment. – Shivang Gangadia Mar 24 '19 at 12:03

0 Answers0