GetManagedType() публичный статический Метод

public static GetManagedType ( int sql_type ) : Type
sql_type int
Результат System.Type
Пример #1
0
        public DB2Command GetUpdateCommand()
        {
            DataTable dt = GetSchema();

            if (updateCommand == null)
            {
                string sets   = "";
                string wheres = "";
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (sets.Length != 0 && !((bool)dt.Rows[i]["IsAutoIncrement"]))
                    {
                        sets += ", ";
                    }
                    if (i != 0)
                    {
                        wheres += " and ";
                    }
                    DataRow    dr     = dt.Rows[i];
                    DataColumn column = new DataColumn((string)dr["ColumnName"], DB2TypeConverter.GetManagedType((int)dr["ProviderType"]));
                    if (!((bool)dr["IsAutoIncrement"]))
                    {
                        sets += String.Format("{0} = ? ", column.ColumnName);
                    }
                    wheres += String.Format("(({0} is null) or ({0} = ?))", column.ColumnName);
                }
                if (tableName == String.Empty)
                {
                    tableName = (string)dt.Rows[0]["BaseTableName"];
                }
                DB2Command cmdaux = new DB2Command("update " + tableName + " set " + sets + " where ( " + wheres + " )", dataAdapter.SelectCommand.Connection);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow    dr     = dt.Rows[i];
                    DataColumn column = new DataColumn((string)dr["ColumnName"], DB2TypeConverter.GetManagedType((int)dr["ProviderType"]));
                    if (!((bool)dr["IsAutoIncrement"]))
                    {
                        DB2Parameter aux = new DB2Parameter("s_" + column.ColumnName, column.DataType);
                        aux.Direction     = ParameterDirection.Input;
                        aux.SourceColumn  = column.ColumnName;
                        aux.SourceVersion = DataRowVersion.Current;
                        cmdaux.Parameters.Add(aux);
                    }
                }
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow      dr     = dt.Rows[i];
                    DataColumn   column = new DataColumn((string)dr["ColumnName"], DB2TypeConverter.GetManagedType((int)dr["ProviderType"]));
                    DB2Parameter aux    = new DB2Parameter("w_" + column.ColumnName, column.DataType);
                    aux.Direction     = ParameterDirection.Input;
                    aux.SourceColumn  = column.ColumnName;
                    aux.SourceVersion = DataRowVersion.Original;
                    cmdaux.Parameters.Add(aux);
                }
                updateCommand = cmdaux;
            }
            return(updateCommand);
        }
Пример #2
0
        public DB2Command GetInsertCommand()
        {
            DataTable dt = GetSchema();

            if (insertCommand == null)
            {
                string fields = "";
                string values = "";
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //DataColumn column = dt.Columns[i];
                    DataRow    dr     = dt.Rows[i];
                    DataColumn column = new DataColumn((string)dr["ColumnName"], DB2TypeConverter.GetManagedType((int)dr["ProviderType"]));

                    if (fields.Length != 0 && !((bool)dr["IsAutoIncrement"]))
                    {
                        fields += ", ";
                        values += ", ";
                    }

                    if (!((bool)dr["IsAutoIncrement"]))
                    {
                        fields += column.ColumnName;
                        //values += ":v_" + column.ColumnName;
                        values += "?";
                    }
                }
                if (tableName == String.Empty)
                {
                    tableName = dt.TableName;
                }
                DB2Command cmdaux = new DB2Command("insert into " + tableName + " (" + fields + ") values (" + values + ")", dataAdapter.SelectCommand.Connection);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //DataColumn column = dt.Columns[i];
                    DataRow    dr     = dt.Rows[i];
                    DataColumn column = new DataColumn((string)dr["ColumnName"], DB2TypeConverter.GetManagedType((int)dr["ProviderType"]));
                    if (!((bool)dr["IsAutoIncrement"]))
                    {
                        DB2Parameter aux = new DB2Parameter("v_" + column.ColumnName, column.DataType);
                        aux.Direction    = ParameterDirection.Input;
                        aux.SourceColumn = column.ColumnName;
                        cmdaux.Parameters.Add(aux);
                    }
                }
                insertCommand = cmdaux;
            }
            return(insertCommand);
        }
Пример #3
0
        public DB2Command GetDeleteCommand()
        {
            DataTable dt = GetSchema();

            if (deleteCommand == null)
            {
                string wheres = "";
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //DataColumn column = row.Table.Columns[i];
                    DataRow    dr     = dt.Rows[i];
                    DataColumn column = new DataColumn((string)dr["ColumnName"], DB2TypeConverter.GetManagedType((int)dr["ProviderType"]));
                    if (i != 0)
                    {
                        wheres += " and ";
                    }
                    //wheres += String.Format("(({0} is null) or ({0} = v_{0}))", column.ColumnName);
                    wheres += String.Format("(({0} is null) or ({0} = ?))", column.ColumnName);
                }
                if (tableName == String.Empty)
                {
                    tableName = (string)dt.Rows[0]["BaseTableName"];
                }
                DB2Command cmdaux = new DB2Command("delete from " + tableName + " where ( " + wheres + " )", dataAdapter.SelectCommand.Connection);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow    dr     = dt.Rows[i];
                    DataColumn column = new DataColumn((string)dr["ColumnName"], DB2TypeConverter.GetManagedType((int)dr["ProviderType"]));

                    DB2Parameter aux = new DB2Parameter("v_" + column.ColumnName, column.DataType);
                    aux.Direction     = ParameterDirection.Input;
                    aux.SourceColumn  = column.ColumnName;
                    aux.SourceVersion = DataRowVersion.Original;
                    cmdaux.Parameters.Add(aux);
                }
                deleteCommand = cmdaux;
            }
            return(deleteCommand);
        }