当前位置: 首页>>代码示例>>C#>>正文


C# SqlDataReader.GetSqlMoney方法代码示例

本文整理汇总了C#中System.Data.SqlClient.SqlDataReader.GetSqlMoney方法的典型用法代码示例。如果您正苦于以下问题:C# SqlDataReader.GetSqlMoney方法的具体用法?C# SqlDataReader.GetSqlMoney怎么用?C# SqlDataReader.GetSqlMoney使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.SqlClient.SqlDataReader的用法示例。


在下文中一共展示了SqlDataReader.GetSqlMoney方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FillCompatibleITypedSettersFromReader

        // Copy multiple fields from reader to ITypedSettersV3
        //  Assumes caller enforces that reader and setter metadata are compatible
        internal static void FillCompatibleITypedSettersFromReader( SmiEventSink_Default sink, ITypedSettersV3 setters, SmiMetaData[] metaData, SqlDataReader reader ) {
            for ( int i = 0; i < metaData.Length; i++ ) {
                if ( reader.IsDBNull(i) ) {
                    ValueUtilsSmi.SetDBNull_Unchecked( sink, setters, i );
                }
                else {
                    switch ( metaData[i].SqlDbType ) {
                        case SqlDbType.BigInt:
                            Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Int64 ) );
                            ValueUtilsSmi.SetInt64_Unchecked( sink, setters, i, reader.GetInt64(i) );
                            break;
                        case SqlDbType.Binary:
                            Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlBytes ) );
                            ValueUtilsSmi.SetSqlBytes_LengthChecked( sink, setters, i, metaData[i], reader.GetSqlBytes(i), 0 );
                            break;
                        case SqlDbType.Bit:
                            Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Boolean ) );
                            SetBoolean_Unchecked( sink, setters, i, reader.GetBoolean(i) );
                            break;
                        case SqlDbType.Char:
                            Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlChars ) );
                            SetSqlChars_LengthChecked( sink, setters, i, metaData[i], reader.GetSqlChars(i), 0 );
                            break;
                        case SqlDbType.DateTime:
                            Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.DateTime ) );
                            SetDateTime_Checked( sink, setters, i, metaData[i], reader.GetDateTime(i) );
                            break;
                        case SqlDbType.Decimal:
                            Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlDecimal ) );
                            SetSqlDecimal_Unchecked( sink, setters, i, reader.GetSqlDecimal(i) );
                            break;
                        case SqlDbType.Float:
                            Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Double ) );
                            SetDouble_Unchecked( sink, setters, i, reader.GetDouble(i) );
                            break;
                        case SqlDbType.Image:
                            Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlBytes ) );
                            SetSqlBytes_LengthChecked( sink, setters, i, metaData[i], reader.GetSqlBytes(i), 0 );
                            break;
                        case SqlDbType.Int:
                            Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Int32 ) );
                            SetInt32_Unchecked( sink, setters, i, reader.GetInt32(i) );
                            break;
                        case SqlDbType.Money:
                            Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlMoney ) );
                            SetSqlMoney_Unchecked( sink, setters, i, metaData[i], reader.GetSqlMoney(i) );
                            break;
                        case SqlDbType.NChar:
                        case SqlDbType.NText:
                        case SqlDbType.NVarChar:
                            Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlChars ) );
                            SetSqlChars_LengthChecked( sink, setters, i, metaData[i], reader.GetSqlChars(i), 0 );
                            break;
                        case SqlDbType.Real:
                            Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Single ) );
                            SetSingle_Unchecked( sink, setters, i, reader.GetFloat(i) );
                            break;
                        case SqlDbType.UniqueIdentifier:
                            Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Guid ) );
                            SetGuid_Unchecked( sink, setters, i, reader.GetGuid(i) );
                            break;
                        case SqlDbType.SmallDateTime:
                            Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.DateTime ) );
                            SetDateTime_Checked( sink, setters, i, metaData[i], reader.GetDateTime(i) );
                            break;
                        case SqlDbType.SmallInt:
                            Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Int16 ) );
                            SetInt16_Unchecked( sink, setters, i, reader.GetInt16(i) );
                            break;
                        case SqlDbType.SmallMoney:
                            Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlMoney ) );
                            SetSqlMoney_Checked( sink, setters, i, metaData[i], reader.GetSqlMoney(i) );
                            break;
                        case SqlDbType.Text:
                            Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlChars ) );
                            SetSqlChars_LengthChecked( sink, setters, i, metaData[i], reader.GetSqlChars(i), 0 );
                            break;
                        case SqlDbType.Timestamp:
                            Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlBytes ) );
                            SetSqlBytes_LengthChecked( sink, setters, i, metaData[i], reader.GetSqlBytes(i), 0 );
                            break;
                        case SqlDbType.TinyInt:
                            Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Byte ) );
                            SetByte_Unchecked( sink, setters, i, reader.GetByte(i) );
                            break;
                        case SqlDbType.VarBinary:
                            Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlBytes ) );
                            SetSqlBytes_LengthChecked( sink, setters, i, metaData[i], reader.GetSqlBytes(i), 0 );
                            break;
                        case SqlDbType.VarChar:
                            Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.String ) );
                            SetSqlChars_LengthChecked( sink, setters, i, metaData[i], reader.GetSqlChars(i), 0 );
                            break;
                        case SqlDbType.Xml:
                            Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlXml ) );
                            SetSqlXml_Unchecked( sink, setters, i, reader.GetSqlXml(i) );
                            break;
                        case SqlDbType.Variant:
//.........这里部分代码省略.........
开发者ID:uQr,项目名称:referencesource,代码行数:101,代码来源:ValueUtilsSmi.cs

示例2: Read

        private List<OkPneuTire> Read(SqlDataReader reader)
        {
            List<OkPneuTire> Tires = new List<OkPneuTire>();

            while (reader.Read())
            {
                OkPneuTire tire = new OkPneuTire();
                tire.EAN = reader.GetString(0);
                tire.Manufacturer = reader.GetString(1);
                tire.Detail = reader.GetInt32(2);
                tire.ExternalStore = reader.GetInt32(3);
                tire.code = reader.GetString(4);
                tire.OnStore = reader.GetInt32(5);
                tire.ProdejniCena = (decimal) reader.GetSqlMoney(6);
                tire.Name = reader.GetString(7);
                tire.Season = reader.GetString(8);
                tire.Description = reader.GetString(9);
                tire.ImageURL = reader.GetString(10);

                Tires.Add(tire);
            }
            return Tires;
        }
开发者ID:KastanOV,项目名称:Dais-project,代码行数:23,代码来源:OkPneuTireTable.cs

示例3: GetMoneyFromReader

    // GetMoneyFromReader safely reads a money column from a reader
    protected double GetMoneyFromReader(string columnname, SqlDataReader reader)
    {
        // Check if parameters are valid
        if (reader == null)
            throw new ArgumentNullException("reader");
        if (columnname == null)
            throw new ArgumentNullException("columnname");
        if (columnname.Length == 0)
            throw new ArgumentException("columnname must not be an empty string");
        int ordinal = -1;

        // Try to find the ordinal number of the column
        try
        {
            ordinal = reader.GetOrdinal(columnname);
        }
        catch (IndexOutOfRangeException)
        {
            // Column was not found so return an empty string
            // TODO: maby show some sort of error
            return -1;
        }

        // Return the column as a string
        return reader.GetSqlMoney(ordinal).ToDouble();
    }
开发者ID:anthonied,项目名称:tcrm,代码行数:27,代码来源:new_clients.aspx.cs

示例4: FillCompatibleITypedSettersFromReader

 internal static void FillCompatibleITypedSettersFromReader(SmiEventSink_Default sink, ITypedSettersV3 setters, SmiMetaData[] metaData, SqlDataReader reader)
 {
     for (int i = 0; i < metaData.Length; i++)
     {
         if (reader.IsDBNull(i))
         {
             SetDBNull_Unchecked(sink, setters, i);
             continue;
         }
         switch (metaData[i].SqlDbType)
         {
             case SqlDbType.BigInt:
             {
                 SetInt64_Unchecked(sink, setters, i, reader.GetInt64(i));
                 continue;
             }
             case SqlDbType.Binary:
             {
                 SetSqlBytes_LengthChecked(sink, setters, i, metaData[i], reader.GetSqlBytes(i), 0);
                 continue;
             }
             case SqlDbType.Bit:
             {
                 SetBoolean_Unchecked(sink, setters, i, reader.GetBoolean(i));
                 continue;
             }
             case SqlDbType.Char:
             {
                 SetSqlChars_LengthChecked(sink, setters, i, metaData[i], reader.GetSqlChars(i), 0);
                 continue;
             }
             case SqlDbType.DateTime:
             {
                 SetDateTime_Checked(sink, setters, i, metaData[i], reader.GetDateTime(i));
                 continue;
             }
             case SqlDbType.Decimal:
             {
                 SetSqlDecimal_Unchecked(sink, setters, i, reader.GetSqlDecimal(i));
                 continue;
             }
             case SqlDbType.Float:
             {
                 SetDouble_Unchecked(sink, setters, i, reader.GetDouble(i));
                 continue;
             }
             case SqlDbType.Image:
             {
                 SetSqlBytes_LengthChecked(sink, setters, i, metaData[i], reader.GetSqlBytes(i), 0);
                 continue;
             }
             case SqlDbType.Int:
             {
                 SetInt32_Unchecked(sink, setters, i, reader.GetInt32(i));
                 continue;
             }
             case SqlDbType.Money:
             {
                 SetSqlMoney_Unchecked(sink, setters, i, metaData[i], reader.GetSqlMoney(i));
                 continue;
             }
             case SqlDbType.NChar:
             case SqlDbType.NText:
             case SqlDbType.NVarChar:
             {
                 SetSqlChars_LengthChecked(sink, setters, i, metaData[i], reader.GetSqlChars(i), 0);
                 continue;
             }
             case SqlDbType.Real:
             {
                 SetSingle_Unchecked(sink, setters, i, reader.GetFloat(i));
                 continue;
             }
             case SqlDbType.UniqueIdentifier:
             {
                 SetGuid_Unchecked(sink, setters, i, reader.GetGuid(i));
                 continue;
             }
             case SqlDbType.SmallDateTime:
             {
                 SetDateTime_Checked(sink, setters, i, metaData[i], reader.GetDateTime(i));
                 continue;
             }
             case SqlDbType.SmallInt:
             {
                 SetInt16_Unchecked(sink, setters, i, reader.GetInt16(i));
                 continue;
             }
             case SqlDbType.SmallMoney:
             {
                 SetSqlMoney_Checked(sink, setters, i, metaData[i], reader.GetSqlMoney(i));
                 continue;
             }
             case SqlDbType.Text:
             {
                 SetSqlChars_LengthChecked(sink, setters, i, metaData[i], reader.GetSqlChars(i), 0);
                 continue;
             }
             case SqlDbType.Timestamp:
             {
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:ValueUtilsSmi.cs

示例5: GetSqlMoneyTest

		public void GetSqlMoneyTest ()
		{
			cmd.CommandText = string.Format (query, "money", "money", "int");
			reader = cmd.ExecuteReader ();
			reader.Read ();
			// Test for standard exceptions 
			GetMethodTests("SqlMoney");

			// Test if data is returned correctly
			Assert.AreEqual (numericRow["type_money"], reader.GetSqlMoney(0).Value,
				"#2 DataValidation Failed");
			reader.Close ();
		}
开发者ID:Profit0004,项目名称:mono,代码行数:13,代码来源:SqlDataReaderTest.cs


注:本文中的System.Data.SqlClient.SqlDataReader.GetSqlMoney方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。