首页 > 编程 > .NET > 正文

使用COBOL.net访问数据库

2024-07-10 13:02:13
字体:
来源:转载
供稿:网友
<@ 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>

  • 本文来源于网页设计爱好者web开发社区http://www.html.org.cn收集整理,欢迎访问。
  • 发表评论 共有条评论
    用户名: 密码:
    验证码: 匿名发表