ASP.NET Database Connection Instance

xiaoxiao2021-03-06  60

using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls Using system.Web.ui.htmlcontrols; using system.data.sqlclient;

Namespace example01 {///

/// WebForm1 summary description. ///

Public class Webform1: System.Web.ui.page

{

Private Void Page_Load (Object Sender, System.EventArgs E)

{

/ / Place the user code here to initialize the page

Response.write (""

The first instance of the connection database

");

SqlConnection myconnection = new SqlConnection ("Server = localhost; uid = sa; pwd = sa");

Try

{

MyConnection.Open (); // Open Database Link

Response.write ("link success!");

}

Catch

{

Response.write ("link failed!");

}

}

#Region Web Form Designer Generated Code Override Protected Void OnNit (Eventargs E) {// // Codegen: This call is required for the ASP.NET Web Form Designer. // InitializeComponent (); base.onit (e);} ///

/// Designer supports the required method - Do not use the code editor to modify the // / this method. ///

Private vidinitiRizeComponent ()

{

This.Load = New System.EventHandler (this.page_load);

}

#ndregion

}

}

转载请注明原文地址:https://www.9cbs.com/read-118945.html

New Post(0)