public class SqlWebDataService : IDataService { public bool IsValid() { WebDataService oService = new WebDataService(); bool retVal = oService.IsValid(); oService.Dispose(); return retVal; } public DataSet ExecuteQuery(IDbCommand Command, string ResultName) { WebDataService oService = new WebDataService (); DataSet dsResult = oService.ExecuteQuery( this.GetSerializedCommand(Command),ResultName); oService.Dispose(); return dsResult; } public void ExecuteNonQuery(IDbCommand Command) { WebDataService oService = new WebDataService (); oService.ExecuteNonQuery( this.GetSerializedCommand(Command)); oService.Dispose(); } public object ExecuteScalar(IDbCommand Command) { WebDataService oService = new WebDataService (); object result = oService.ExecuteScalar( this.GetSerializedCommand(Command)); oService.Dispose(); return result; } public IDbCommand GetCommandObject() { return new SqlCommand(); } public void AddCommandParameter(IDbCommand command, string parameterName, object parameterValue) { SqlCommand myCommand = (SqlCommand)command; myCommand.Parameters.Add(parameterName,parameterValue); } private string GetSerializedCommand(IDbCommand command) { SqlCommand cmd = (SqlCommand)command; StringBuilder sb = new StringBuilder(); sb.Append( "\r\n"); sb.Append("\r\n"); sb.Append(" "+command.CommandText+"\r\n"); sb.Append(" "+ command.CommandType.ToString()+"\r\n"); sb.Append(" \r\n"); foreach(SqlParameter para in cmd.Parameters) { sb.Append(" "); sb.Append(para.Value.ToString()); sb.Append("\r\n"); } sb.Append(" \r\n"); sb.Append("\r\n"); return sb.ToString(); } }