Beispiel #1
0
 public DataSet ExecuteSQLQuery(string sqlQuery)
 {
     try
     {
         mySQLConnection = new SqlConnection(this.sSQLConnectionString);
         mySQLAdapter    = new SqlDataAdapter(sqlQuery, mySQLConnection);
         myDataSet       = new DataSet();
         mySQLConnection.Open();
         mySQLAdapter.FillSchema(myDataSet, SchemaType.Source);
         mySQLAdapter.Fill(myDataSet);
     }
     catch (Exception e)
     {
         MetriconCommon.LogToFile("", "", "ServerManager.ExecuteSQLQuery", e.Message.ToString());
     }
     finally
     {
         //if there are no tables add default table
         if (myDataSet.Tables.Count == 0)
         {
             myDataSet.Tables.Add(new DataTable("NoRecords"));
         }
         mySQLConnection.Close();
         mySQLConnection.Dispose();
     }
     return(myDataSet);
 }
Beispiel #2
0
    public bool LoadVariablesFromFile()
    {
        //loading from web.config file
        MetriconCommon.LogToFile("", "", "ServerManager.LoadVariablesFromFile", "");
        SetConnectionString();


        return(true);
    }
Beispiel #3
0
    public DataSet ExecuteSQLQuery(string sqlStoredProcedure, SqlParameter[] myParameters)
    {
        try
        {
            mySQLConnection = new SqlConnection(this.sSQLConnectionString);
            mySQLAdapter    = new SqlDataAdapter(sqlStoredProcedure, mySQLConnection);
            myDataSet       = new DataSet();

            //mySQLAdapter.SelectCommand = new SqlCommand(sqlStoredProcedure);
            mySQLAdapter.SelectCommand.CommandTimeout = 7200;
            mySQLAdapter.SelectCommand.Connection     = mySQLConnection;
            mySQLAdapter.SelectCommand.CommandType    = CommandType.StoredProcedure;

            mySQLConnection.Open();
            foreach (SqlParameter tempParam in myParameters)
            {
                mySQLAdapter.SelectCommand.Parameters.Add(tempParam);
            }

            mySQLAdapter.Fill(myDataSet);
        }
        catch (Exception e)
        {
            MetriconCommon.LogToFile("", "", "ServerManager.ExecuteSQLQuery", e.Message.ToString());
            throw e;
        }
        finally
        {
            //if there are no tables add default table
            if (myDataSet.Tables.Count == 0)
            {
                myDataSet.Tables.Add(new DataTable("NoRecords"));
            }
            mySQLConnection.Close();
            mySQLConnection.Dispose();
        }
        return(myDataSet);
    }