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

Пример 3.7

/// <summary> /// Adds a new event to system /// </summary> [WebMethod] public bool Add() { System.Data.SqlClient.SqlDataReader myEvent;

try { //set state for the command object instance InsertEvent.Parameters["@Name"].Value =mEvent.Name;

InsertEvent.Parameters["@StartDate"].Value =mEvent.DateTime;

InsertEvent.Parameters["@Description"].Value =mEvent.Description;

//open the connection object ServicesDBConn.Open();

//run query myEvent = this.InsertEvent.ExecuteReader();

//must advance to first record myEvent.Read();

//fill local properties mEvent.ID = myEvent.GetInt32(3);

//shut down record myEvent.Close(); } catch(System.Exception Err ) { //log error this.LogMessage(Err.ToString() , true);

//rethrow for client consumption throw Err; }

//success if we get this far return true; }

Листинг 3.7. Add Function in Events Web Service

Закрыть окно

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