使用perl.net訪問資料庫
來源:互聯網
上載者:User
perl|訪問|資料|資料庫 不只是vb.net,C#等微軟的開發軟體可以調用.net framework,據我所知至少有28中我知道的開發語言如何調用.net framework.下面我就給出一段案例,說明使用perl.net來訪問資料庫
<%@ Page Language="Perl" %>
<script runat="server">
use namespace "System::Data";
use namespace "System::Data::SqlClient";
=for interface
protected override void OnLoad(System.EventArgs e);
=cut
sub OnLoad {
my($this, $e) = @_;
my $myConnection = SqlConnection->new("Data Source=(local); Trusted_Connection=Yes; Initial Catalog=pubs");
my $myCommand = SqlCommand->new("Select * From Publishers", $myConnection);
$myConnection->Open();
$this->{myDataGrid}{DataSource} = $myCommand->ExecuteReader(PerlNET::enum("CommandBehavior.CloseConnection"));
$this->{myDataGrid}->DataBind;
}
</script>
<html>
<body>
<form runat="server">
<asp:DataGrid id="myDataGrid" runat="server" />
</form>
</body>
</html>