Delphi Russian Knowledge Base
DRKB - это самая большая и удобная в использовании база знаний по Дельфи в рунете, составленная Виталием Невзоровым

Как создать консольное ASP.NET приложение с событиями Delphi?

****************** Below is a complete listing for an ASPX file to open and
read an ACCESS database. Obviously the source=c:\mydb.mdb declaration should
be changed to point to your own database. The sql commands will also need to
be ammended to point to the correct tables and values. This souce code is a
translation from native c#. Any problems with the code or , thanks, comments
or general abuse over codeing standrds should be sent to,
Please put "delphi" in the subject line so I can junk filter.

Good luck.....

As another issue I've also got some examples I've written for Delphi for Dot Net
doing similar stuff


<%@ Page Language="Delphi" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">
  procedure Button1Click(Sender: System.Object; E: EventArgs);
      MyConnection : OleDbConnection ;
      dbReader : OleDbDataReader;
      cmd : OleDbCommand;
      abc : string;
      outval : string;
      intval : longint;
    abc := 'Provider=Microsoft.Jet.OLEDB.4.0;Password=;Data Source=c:\mydb.mdb';
    MyConnection := OleDbConnection.Create(abc);
    cmd := MyConnection.CreateCommand;
    cmd.CommandText := 'Select * from Table1';
    dbReader := cmd.ExecuteReader;
    while (dbReader.Read) do
        intval := dbReader.GetInt32(0);
        outval := dbReader.GetString(1);
    Label1.Text := inttostr(intval);

  procedure Button2Click(Sender: System.Object; E: EventArgs);
     ConnStr : string;
     CommTxt : string;
     MyConnection : OleDbConnection ;
     abc : string;
     cmdText : string;
     cmd : OleDbCommand;

    ConnStr := 'Provider=Microsoft.Jet.OLEDB.4.0;Password=;Data Source=c:\mydb.mdb';
    CommTxt := 'select andy as [first name], chapman as [Last Name] from Table1';
    abc := 'Provider=Microsoft.Jet.OLEDB.4.0;Password=;Data Source=c:\mydb.mdb';
    MyConnection := OleDbConnection.Create(abc);
    cmd := OleDbCommand.Create(CommTxt,MyConnection);
    DataGrid1.DataSource := cmd.ExecuteReader(CommandBehavior.CloseConnection);
<body style="FONT-FAMILY: arial">
    <h2>Simple Data Report
    <hr size="1" />
    <form runat="server">
        <asp:datagrid class="DataGrid1" runat="server" CellSpacing="1" GridLines="None" CellPadding="3" BackColor="White" ForeColor="Black" EnableViewState="False">
            <HeaderStyle font-bold="True" forecolor="White" backcolor="#4A3C8C"></HeaderStyle>
            <ItemStyle backcolor="#DEDFDE"></ItemStyle>
        <asp:Button class="Button1" style="Z-INDEX: 100; LEFT: 284px; POSITION: absolute; TOP: 151px" onclick="Button1Click" runat="server" Text="Bind To Data Grid"></asp:Button>
        <asp:Label class="Label1" style="Z-INDEX: 100; LEFT: 467px; POSITION: absolute; TOP: 156px" runat="server" Width="42px">Label</asp:Label>
        <asp:Button class="Button2" style="Z-INDEX: 101; LEFT: 283px; POSITION: absolute; TOP: 182px" onclick="Button2Click" runat="server" Text="Button"></asp:Button>

To make the code execute locally you should download webmatrix which is an

excellent free downloadable aspx development environment. All you need then

is the following code in a web.config document:


<compilation debug="true">
  <add assembly="DelphiProvider" />
                <compiler language="Delphi" extension=".pas" type="Borland.Delphi.DelphiCodeProvider,DelphiProvider" />

and inside a bin directory at the root the DelphiProvider.dll.

You may now create and run applications with delphi as you chosen

method of codeing.