熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

ASP.NET 鏈接數據庫基礎教程

2022-06-13   來源: .NET編程 

  indexaspx
  
  <%@ Page Language=C# %>
  <%@ import Namespace=SystemData %>
  <%@ import Namespace=SystemDataOleDb %>
  <script runat=server>
  
  // Insert page code here
  //
  void Page_Load(){
  string db=@database/datamdb;
  string connStr=PROVIDER=MicrosoftJetOLEDB;DATA Source=+ServerMapPath(db)+;;
  
  string SQLcmd=create table IEB_webs(ID identity primary keytitle varchar() Default Null);
  
  OleDbConnection conn=new OleDbConnection(connStr);
  connOpen();
  OleDbCommand OleCmd=new OleDbCommand(SQLcmdconn);
  
  OleCmdExecuteNonQuery();   //執行SQL命令
  
  ResponseWrite(數據表建立完成!);
  }
  
  connClose();
  conn=null;
  OleCmd=null;
  
  }
  
  </script>
  <html>
  <head>
  </head>
  <body>
  <form method=post runat=server>
  <! Insert content here >
  </form>
  </body>
  </html>
From:http://tw.wingwit.com/Article/program/net/201311/12081.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.