---------- 20191028 http://webbo.sourceforge.net/tut_aspnet_sqlite.php Accessing a SQLite Database from ASP.NET In the previous tutorial we created a basic ASP.NET application and added a SQLite database of Formula 1 racing world champions. In this tutorial we will extend the application to present the data. Enabling the SQLite data provider Webbo is able to access SQLite databases because it comes complete with its own built in data provider 'System.Data.SQLite.dll' which is located in the Webbo installation directory (usually 'C:\Program Files\Webbo'). To allow our application to access the database we need to give it access to this provider. First, in the application root directory create a new folder named 'bin' and copy 'System.Data.SQLite.dll' into it. The project should now look like this: Next, edit 'Web.config' and add the following code between the end of the section named 'system.web' and the start of the section named 'system.codedom': This allows ASP.NET to identify the provider and load the assembly when data access is requested. Creating a connection To allow our application to access the SQLite database we need to define a connection string. In 'Web.config' add a new element to the connection string section so that it looks like this: This creates a connection named 'F1Champs' and instructs ASP.NET to open the 'F1Champs.sqlite' database located in the data directory ('App_Data') using the SQLite data provider. Note the shortcut name for 'App_Data' and the provider name we defined earlier. Save the file, start the ASP.NET development server and preview the site by pressing Ctrl+F9 or clicking the toolbar button: a blank page should appear. Now let's add some controls to present the data. Adding the data controls First we need to add a SqlDataSource control to provide a link to the database. This defines the data provider, connection string and SQL command to be used to retrieve the data for the page. Open 'Default.aspx' and create a new line between the form tags. Type ' Note the shortcut for referencing the connection string: use this format to reference any item in the 'connectionStrings' section of 'Web.config'. We also need to specify the provider name; unless told otherwise the control will attempt to access a SQL Server so we need to specify SQLite instead. Finally, the 'SelectCommand' defines the SQL query we need to retrieve the data for our page. In this case we are requesting the data for this century, to be listed in reverse chronological order. Now we have some data we need a presentation control to make it visible on the page. After the SqlDataSource control start a new line, access Code Assist and insert a GridView control. Provide an ID and use the Code Assist to complete the remaining attributes of the control. After the ID type a space and press ctrl+space, a list of attributes should appear. Select 'DataSourceID' and set its value to the ID of the SqlDataSource control ('F1Champs'). Type another space and use Code Assist to insert the 'AutoGenerateColumns' attribute, set its value to 'true'. Preview the page by pressing ctrl+F9; the data should appear in the grid. The page should look like this: <%@ Page Language="C#" AutoEventWireup="true" %>