Программирование в IIS




Пример 3.3


public class Events : System.Web.Services.WebService { //locals to class private System.Data.SqlClient.SqlConnection myConn;

public Events() { //CODEGEN: This call is required by the //ASP.NET Web Services Designer InitializeComponent();

System.Configuration.AppSettingsReader myAppSettings = new System.Configuration.AppSettingsReader();

//get the connection string from web.config string sConnect = ((string) (myAppSettings.GetValue ("ProductionDB.ConnectionString", typeof(string))));

//make the DB connection myConn = new System.Data.SqlClient.SqlConnection(sConnect); }

#region Component Designer generated code

//Required by the Web Services Designer private IContainer components = null;

/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if(disposing && components != null) { components.Dispose(); } base.Dispose(disposing); }

#endregion }

Листинг 3.3. Using SQLConnection Object without the Designer and Obtaining Connection String from the web.config File

Закрыть окно






Содержание  Назад  Вперед