访问|数据|数据库
<@ Page language="COBOL">
<html>
<head>
<script runat="server" language="COBOL">
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
REPOSITORY.
PROPERTY DataSource
PROPERTY myDataGrid
CLASS SqlConnection AS "System.Data.SqlClient.SqlConnection"
CLASS SqlCommand AS "System.Data.SqlClient.SqlCommand"
CLASS SqlDataReader AS "System.Data.SqlClient.SqlDataReader"
CLASS Sys-EventArgs AS "System.EventArgs"
CLASS Sys-Type AS "System.Type".
OBJECT.
PROCEDURE DIVISION.
METHOD-ID. ONLOAD AS "OnLoad" OVERRIDE.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 mySqlConnection OBJECT REFERENCE SqlConnection.
01 mySqlCommand OBJECT REFERENCE SqlCommand.
01 mySqlDataReader OBJECT REFERENCE SqlDataReader.
01 myType OBJECT REFERENCE Sys-Type.
01 dataSource OBJECT REFERENCE ICollection.
LINKAGE SECTION.
01 args OBJECT REFERENCE Sys-EventArgs.
PROCEDURE DIVISION USING BY VALUE args.
INVOKE SUPER "OnLoad" USING BY VALUE args.
INVOKE SqlConnection "New" USING BY VALUE "Data Source=(local); Trusted_Connection=Yes;
Initial Catalog=pubs" RETURNING mySqlConnection.
INVOKE SqlCommand "New" USING BY VALUE "Select * From Publishers" mySqlConnection
RETURNING mySqlCommand.
INVOKE mySqlConnection "Open".
INVOKE mySqlCommand "ExecuteReader" RETURNING mySqlDataReader.
SET DataSource OF myDataGrid TO mySqlDataReader.
INVOKE myDataGrid "DataBind".
INVOKE mySqlConnection "Close".
END METHOD ONLOAD.
END OBJECT.
</script>
</head>
<body>
<form runat="server">
<asp:DataGrid id="myDataGrid" runat="Server" />
</form>
</body>
</html>