Exemplo n.º 1
0
 public static bool ActionExecuteStoreProcedureForDT(class_data_PlatformDBConnection activeconnection, class_Data_SqlSPEntry activeSPEntry, out DataTable resultDT)
 {
     resultDT = null;
     try
     {
         if (activeSPEntry == null)
         {
             return(false);
         }
         else
         {
             if (activeconnection != null && activeconnection.activeDatabaseType == enum_DatabaseType.SqlServer)
             {
                 SqlCommand cmd = new SqlCommand();
                 cmd.CommandText = activeSPEntry.SPName;
                 cmd.CommandType = CommandType.StoredProcedure;
                 foreach (SqlParameter activeParameter in ((class_data_SqlServerSPEntry)activeSPEntry).GetActiveParametersList())
                 {
                     cmd.Parameters.Add(activeParameter);
                 }
                 cmd.Connection = ((class_data_SqlServerConnectionItem)activeconnection).ActiveConnection;
                 SqlDataAdapter sda = new SqlDataAdapter(cmd);
                 resultDT = new DataTable();
                 sda.Fill(resultDT);
                 return(true);
             }
             else if (activeconnection != null && activeconnection.activeDatabaseType == enum_DatabaseType.MySql)
             {
                 MySqlCommand cmd = new MySqlCommand();
                 cmd.CommandText = activeSPEntry.SPName;
                 cmd.CommandType = CommandType.StoredProcedure;
                 foreach (MySqlParameter activeParameter in ((class_data_MySqlSPEntry)activeSPEntry).GetActiveParametersList())
                 {
                     cmd.Parameters.Add(activeParameter);
                 }
                 cmd.Connection = ((class_data_MySqlConnectionItem)activeconnection).ActiveConnection;
                 MySqlDataAdapter sda = new MySqlDataAdapter(cmd);
                 resultDT = new DataTable();
                 sda.Fill(resultDT);
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 2
0
 public static bool ActionExecuteSPForNonQuery(class_data_PlatformDBConnection activeconnection, class_Data_SqlSPEntry activeSPEntry)
 {
     try
     {
         if (activeSPEntry == null)
         {
             return(false);
         }
         else
         {
             if (activeconnection != null && activeconnection.activeDatabaseType == enum_DatabaseType.SqlServer)
             {
                 SqlCommand cmd = new SqlCommand();
                 cmd.CommandText = activeSPEntry.SPName;
                 cmd.CommandType = CommandType.StoredProcedure;
                 foreach (SqlParameter activeParameter in ((class_data_SqlServerSPEntry)activeSPEntry).GetActiveParametersList())
                 {
                     cmd.Parameters.Add(activeParameter);
                 }
                 cmd.Connection = ((class_data_SqlServerConnectionItem)activeconnection).ActiveConnection;
                 cmd.ExecuteNonQuery();
                 return(true);
             }
             else if (activeconnection != null && activeconnection.activeDatabaseType == enum_DatabaseType.MySql)
             {
                 try
                 {
                     MySqlCommand cmd = new MySqlCommand();
                     cmd.CommandText = activeSPEntry.SPName;
                     cmd.CommandType = CommandType.StoredProcedure;
                     foreach (MySqlParameter activeParameter in ((class_data_MySqlSPEntry)activeSPEntry).GetActiveParametersList())
                     {
                         cmd.Parameters.Add(activeParameter);
                     }
                     cmd.Connection = ((class_data_MySqlConnectionItem)activeconnection).ActiveConnection;
                     MySqlDataAdapter sda = new MySqlDataAdapter(cmd);
                     cmd.ExecuteNonQuery();
                     return(true);
                 }
                 catch (Exception err)
                 {
                     return(false);
                 }
             }
             else
             {
                 return(false);
             }
         }
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 3
0
 public static bool ActionExecuteStoreProcedureForDR(class_data_PlatformDBConnection activeconnection, class_Data_SqlSPEntry activeSPEntry, out class_data_PlatformDBDataReader refDataReader)
 {
     refDataReader = null;
     try
     {
         if (activeSPEntry == null)
         {
             return(false);
         }
         else
         {
             if (activeconnection != null && activeconnection.activeDatabaseType == enum_DatabaseType.SqlServer)
             {
                 SqlCommand cmd = new SqlCommand();
                 cmd.CommandText = activeSPEntry.SPName;
                 cmd.CommandType = CommandType.StoredProcedure;
                 foreach (SqlParameter activeParameter in ((class_data_SqlServerSPEntry)activeSPEntry).GetActiveParametersList())
                 {
                     cmd.Parameters.Add(activeParameter);
                 }
                 cmd.Connection = ((class_data_SqlServerConnectionItem)activeconnection).ActiveConnection;
                 refDataReader  = new class_data_PlatformDBDataReader();
                 refDataReader.activeDatabaseType = enum_DatabaseType.SqlServer;
                 ((class_data_SqlServerDataReader)refDataReader).ActiveDataReader = cmd.ExecuteReader();
                 return(true);
             }
             else if (activeconnection != null && activeconnection.activeDatabaseType == enum_DatabaseType.MySql)
             {
                 MySqlCommand cmd = new MySqlCommand();
                 cmd.CommandText = activeSPEntry.SPName;
                 cmd.CommandType = CommandType.StoredProcedure;
                 foreach (MySqlParameter activeParameter in ((class_data_MySqlSPEntry)activeSPEntry).GetActiveParametersList())
                 {
                     cmd.Parameters.Add(activeParameter);
                 }
                 cmd.Connection = ((class_data_MySqlConnectionItem)activeconnection).ActiveConnection;
                 refDataReader  = new class_data_PlatformDBDataReader();
                 refDataReader.activeDatabaseType = enum_DatabaseType.MySql;
                 ((class_data_MySqlDataReader)refDataReader).ActiveDataReader = cmd.ExecuteReader();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch
     {
         return(false);
     }
 }