Пример #1
0
 private void ObtainSpInfo()
 {
     this.m_Params = new SqlSpParamInfoArray();
     DataSet dataSet = new DataSet();
     SqlCommand selectCommand = new SqlCommand(string.Format("exec sp_sproc_columns '{0}'", this.Name), this.InfoRoot.SqlConn);
     new SqlDataAdapter(selectCommand).Fill(dataSet, "Params");
     foreach (DataRow row in dataSet.Tables[0].Rows)
     {
       SqlSpParamInfo spParamInfo = new SqlSpParamInfo(this, row);
       this.m_Params.Add(spParamInfo);
     }
     if (this.InfoRoot.SqlConn.State != ConnectionState.Open)
     {
       this.InfoRoot.SqlConn.Open();
     }
     new SqlCommand("SET NO_BROWSETABLE ON", this.InfoRoot.SqlConn).ExecuteNonQuery();
     string str2 = string.Empty;
     string str3 = "exec " + this.Name + " ";
     string str4 = string.Empty;
     int num = 1;
     foreach (DataRow row2 in dataSet.Tables[0].Rows)
     {
       if (((short)row2["COLUMN_TYPE"]) != 5)
       {
     str2 = str2 + string.Format("@P{0} {1}, ", num, SqlTypeMap.GetFullTypeName(row2));
     str3 = str3 + string.Format("{0}=@P{1}, ", (string)row2["COLUMN_NAME"], num);
     str4 = str4 + string.Format("{0}, ", SqlTypeMap.GetPreparationValue(row2));
     num++;
       }
     }
     if (num > 1)
     {
       str2 = str2.Substring(0, str2.Length - 2);
       str3 = str3.Substring(0, str3.Length - 2);
       str4 = str4.Substring(0, str4.Length - 2);
     }
     selectCommand = new SqlCommand("exec sp_prepare @P1 output, N'" + str2 + "', N'" + str3 + "', 1", this.InfoRoot.SqlConn);
     SqlParameter parameter = selectCommand.Parameters.Add("@P1", SqlDbType.Int);
     parameter.Direction = ParameterDirection.Output;
     selectCommand.ExecuteNonQuery();
     int num2 = (int)parameter.Value;
     new SqlCommand("SET FMTONLY ON", this.InfoRoot.SqlConn).ExecuteNonQuery();
     selectCommand = new SqlCommand("exec sp_execute " + num2.ToString() + ((str4 != string.Empty) ? ", " : "") + str4, this.InfoRoot.SqlConn);
     SqlDataAdapter adapter = new SqlDataAdapter(selectCommand);
     try
     {
       adapter.Fill(dataSet, "Resultset");
       this.m_ResultInfo = dataSet.Tables["Resultset"].Columns;
     }
     catch
     {
     }
     new SqlCommand("SET FMTONLY OFF", this.InfoRoot.SqlConn).ExecuteNonQuery();
     new SqlCommand("exec sp_unprepare " + num2.ToString(), this.InfoRoot.SqlConn).ExecuteNonQuery();
     new SqlCommand("SET NO_BROWSETABLE OFF", this.InfoRoot.SqlConn).ExecuteNonQuery();
     this.InfoRoot.SqlConn.Close();
 }
Пример #2
0
 public void Reload()
 {
     this.m_Params = null;
     this.m_ResultInfo = null;
 }