From: Carlos G. A. <car...@te...> - 2003-02-26 10:10:53
|
Hello: > Thanks so much for your help, I didn't realize that your source file had > examples and only had the help file to work with so I was a bit lost. At any > rate, your samples set me right and I have a working model and as promised > I'm including the sample code. We plan on using your product for all our > asp.net development with Delphi. :) Thanks very much. Best regards Carlos Guzma'n A'lvarez Vigo-Spain <%@ Page Language="delphi" %> <%@ import Namespace="System.Data" %> <%@ import Namespace="FirebirdSql.Data.Firebird" %> <script runat="server"> const ProdName = 'Delphi for .NET'; DispFields = 'OrderID, CustomerID, ShipName, ShipCity, ShipCountry'; procedure DateSelected(Sender: System.Object; E: EventArgs); begin Label1.Text := ProdName + ' says you picked ' + Calendar1.SelectedDate.ToString('D'); DataGrid1.DataSource := GetOrders(Calendar1.SelectedDate); DataGrid1.DataBind; end; procedure Button1Click(Sender: System.Object; E:EventArgs); begin Calendar1.VisibleDate := System.Convert.ToDateTime(Edit1.Text); Label1.Text := ProdName + ' says you set ' + Calendar1.VisibleDate.ToString('D'); end; procedure Button2Click(Sender: System.Object; E:EventArgs); begin DisplayFields.Text := DispFields; end; function GetOrders(Date : DateTime) : DataSet; var Adapter : FbDataAdapter ; command: FbCommand; connection: FBConnection; transaction: FBTransaction; ds: DataSet; MyConnectionString:string; builder:FbCommandBuilder; begin MyConnectionString := 'Database=d:\projects\data\disdat.GDB;User=SYSDBA;Password=masterkey;Dialect =1;Server=localhost'; connection:=FBConnection.create(MyConnectionString); connection.open; transaction:=Connection.BeginTransaction; command := FbCommand.create('select * from code', connection, transaction); adapter := FbDataAdapter.create(command); builder := FbCommandBuilder.create(adapter); Result := DataSet.Create; adapter.Fill(Result, 'code'); label2.text:='Adap fill'; transaction.commit; connection.close; command.free; adapter.free; builder.free; end; </script> <html> <head> </head> <body style="FONT: 18pt Verdana"> <form runat="server"> <h1><%=ProdName %>with a Calendar, DataGrid, & SqlClient in ASP.NET </h1> <table> <tbody> <tr valign="top"> <td> <p> <b>Pick a date</b> </p> <asp:Calendar id="Calendar1" runat="server" ForeColor="#0000FF" BackColor="#FFFFCC" OnSelectionChanged="DateSelected"> <TodayDayStyle font-bold="True" /> <NextPrevStyle forecolor="#FFFFCC" /> <DayHeaderStyle backcolor="#FFCC66" /> <SelectedDayStyle forecolor="Black" backcolor="#CCCCFF" /> <TitleStyle font-size="14pt" font-bold="True" forecolor="#FFFFCC" backcolor="#990000" /> <OtherMonthDayStyle forecolor="#CC9966" /> </asp:Calendar> <p> <asp:TextBox id="Edit1" runat="server" width="150"></asp:TextBox> <asp:Button id="Button1" onclick="DateSelected" runat="server" text="Set date"></asp:Button> </p> </td> <td valign="top"> <p> <b>Display fields:</b> <asp:TextBox id="DisplayFields" runat="server" width="500" text="OrderID, CustomerID, ShipName, ShipCity, ShipCountry"></asp:TextBox> <asp:Button id="Button2" onclick="Button2Click" runat="server" text="Reset fields"></asp:Button> <asp:Button id="Button3" onclick="DateSelected" runat="server" Text="Button"></asp:Button> </p> <p> <a href="http://localhost/scripts/dategrid.aspx">http://localhost/scripts/dateg rid.aspx</a> </p> <asp:DataGrid id="DataGrid1" runat="server" ForeColor="#0000FF" BorderColor="#FFCC66"> <HeaderStyle forecolor="#FFFFCC" backcolor="#990000" /> </asp:DataGrid> </td> </tr> </tbody> </table> <p> <asp:Label id="Label1" runat="server"></asp:Label> </p> <p> <asp:Label id="Label2" runat="server"></asp:Label> </p> </form> The data connectivity </body> </html> |