///<summary> ///Creates and returns a command object on oConn ///from the stored procedure specified in the Sql property. ///Fills the stored procedure parameters from either the request.querystring ///or request.form collection depending on whether the page is post or get. ///</summary> private ADODB.Command CreateCommand(ref ADODB.Connection oConn) { OpenConnection(ref oConn); ADODB.Command oCmd = new ADODB.CommandClass(); oCmd.ActiveConnection = oConn; oCmd.CommandType = ADODB.CommandTypeEnum.adCmdStoredProc; oCmd.CommandText = Sql; oCmd.Parameters.Refresh(); NameValueCollection Req = (Page.Request.HttpMethod == "POST")?Page.Request.Form:Page.Request.QueryString; foreach (ADODB.Parameter P in oCmd.Parameters) { string st = Req[P.Name.Substring(1)]; if (st != null && st != "") { P.Value = st; } } return(oCmd); }
public StoredProcedureNodeViewModel(ADOX.Procedure procedure, ADODB.Connection connection, NodeViewModel parent) : base(parent) { if (null == procedure) { throw new ArgumentNullException("procedure"); } if (null == connection) { throw new ArgumentNullException("connection"); } string procedureName = procedure.Name; Regex matchSPName = new Regex(@"(.*);\d+"); Match match = matchSPName.Match(procedureName); if (match.Success && match.Groups.Count == 2) { procedureName = match.Groups[1].Value; } AllowDrag = true; Text = procedureName; List <string> paremeterNames = new List <string>(); ADODB.Command command = new ADODB.CommandClass(); command.ActiveConnection = connection; command.CommandType = ADODB.CommandTypeEnum.adCmdStoredProc; command.CommandText = procedureName; command.Parameters.Refresh(); var parameterNames = GetParameterNames(command.Parameters); ConfigureParameters(procedureName, parameterNames); }