Mega Code Archive

 
Categories / Delphi / .NET
 

Create and control asp.net programs with delphi events

Title: create and control asp.net programs with delphi events? (* ****************** 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 andychap@hotmail.com, 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 ********************************************************************************** *) procedure Button1Click(Sender: System.Object; E: EventArgs); var MyConnection : OleDbConnection ; dbReader : OleDbDataReader; cmd : OleDbCommand; abc : string; outval : string; intval : longint; begin abc := 'Provider=Microsoft.Jet.OLEDB.4.0;Password=;Data Source=c:\mydb.mdb'; MyConnection := OleDbConnection.Create(abc); MyConnection.Open; cmd := MyConnection.CreateCommand; cmd.CommandText := 'Select * from Table1'; dbReader := cmd.ExecuteReader; while (dbReader.Read) do begin intval := dbReader.GetInt32(0); outval := dbReader.GetString(1); end; Label1.Text := inttostr(intval); end; procedure Button2Click(Sender: System.Object; E: EventArgs); var ConnStr : string; CommTxt : string; MyConnection : OleDbConnection ; abc : string; cmdText : string; cmd : OleDbCommand; begin 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); MyConnection.Open; DataGrid1.DataSource := cmd.ExecuteReader(CommandBehavior.CloseConnection); DataGrid1.DataBind(); end; Simple Data Report absolute; TOP: 151px" onclick="Button1Click" runat="server" Text="Bind To Data Grid" Label id="Label1" style="Z-INDEX: 100; LEFT: 467px; POSITION: absolute; TOP: 156px" runat="server" Width="42px"LabelLabel absolute; TOP: 182px" onclick="Button2Click" runat="server" Text="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 : *) type="Borland.Delphi.DelphiCodeProvider,DelphiProvider" / (* and inside a bin directory at the root the DelphiProvider.dll. You may now create and run asp.net applications with delphi as you chosen method of codeing. *)