예제 #1
0
    public static int ProccesApply(string tableName, string columnName, object id, object value)
    {
        int rowsAffected = 0;

        using (BAYMYO.MultiSQLClient.MConnection cnn = new BAYMYO.MultiSQLClient.MConnection(BAYMYO.MultiSQLClient.MClientProvider.MSSQL))
        {
            switch (cnn.State)
            {
            case System.Data.ConnectionState.Closed:
                cnn.Open();
                break;
            }
            using (BAYMYO.MultiSQLClient.MCommand cmd = new BAYMYO.MultiSQLClient.MCommand(System.Data.CommandType.Text, string.Format("UPDATE {0} SET {1}=@Value WHERE ID=@ID", tableName, columnName), cnn))
            {
                cmd.Parameters.Add("ID", id);
                cmd.Parameters.Add("Value", value);
                rowsAffected = BAYMYO.MultiSQLClient.MConvert.NullToInt(cmd.ExecuteNonQuery());
            }
            switch (cnn.State)
            {
            case System.Data.ConnectionState.Open:
                cnn.Close();
                break;
            }
        }
        return(rowsAffected);
    }
예제 #2
0
        internal static bool ConnectionStates()
        {
            bool rv = false;

            try
            {
                Commons.ConnectionStringName = string.Format("Provider=Microsoft.Jet.Oledb.4.0;Data Source={0};Persist Security Info=False;", Commons.AppSettings.DATABASE);
                using (BAYMYO.MultiSQLClient.MConnection cnn = new BAYMYO.MultiSQLClient.MConnection(BAYMYO.MultiSQLClient.MClientProvider.OleDb, Commons.ConnectionStringName))
                {
                    cnn.Open();
                    switch (cnn.State)
                    {
                    case System.Data.ConnectionState.Broken:
                    case System.Data.ConnectionState.Closed:
                    case System.Data.ConnectionState.Fetching:
                        rv = false;
                        break;

                    case System.Data.ConnectionState.Open:
                        rv = true;
                        cnn.Close();
                        break;
                    }
                }
                return(rv);
            }
            catch (Exception)
            {
                return(false);
            }
        }