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


C# SqlDataReader.GetSqlBinary方法代码示例

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


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

示例1: Documents

 private Documents(SqlDataReader data)
 {
     ID = data.GetInt32(0);
     Name = data.GetString(1);
     hash = data.GetString(2);
     buffer = data.GetSqlBinary(3).Value;
 }
开发者ID:JackJCSN,项目名称:APMS,代码行数:7,代码来源:Documents.cs

示例2: getTableStringArray

        private static List<String[]> getTableStringArray(SqlDataReader reader, SqlString PrintOnlyColumnNameAliasList)
        {
            DataTable schema = reader.GetSchemaTable();

            List<String[]> results = new List<string[]>();

            int numCols = schema.Rows.Count;

            if (PrintOnlyColumnNameAliasList.ToString().Equals(""))
            {
                String[] header = new String[numCols];
                for (int i = 0; i < numCols; i++)
                {
                    DataRow row = schema.Rows[i];
                    header[i] = (row["ColumnName"].ToString());
                }
                results.Add(header);
            }
            else
            {
                var colListArray = SplitColumnNameList(ref PrintOnlyColumnNameAliasList);
                var unquotedColList = new List<string>();

                foreach(var colName in colListArray)
                {
                    if (colName.Length != 0)
                    {
                        unquotedColList.Add(colName.Replace("]]", "]"));
                    }
                }

                results.Add(unquotedColList.ToArray());
            }

            while (reader.Read()) {
                String[] rowData = new String[numCols];
                for (int i = 0; i < reader.FieldCount; i++) {

                    if (reader.IsDBNull(i)) {
                        rowData[i] = NULL_STRING;
                    } else {
                        SqlDbType dbType = (SqlDbType)schema.Rows[i]["ProviderType"];

                        switch (dbType) {
                            case SqlDbType.Date:
                                rowData[i] = SqlDateToString(reader.GetDateTime(i));
                                break;
                            case SqlDbType.SmallDateTime:
                                rowData[i] = SmallDateTimeToString(reader.GetDateTime(i));
                                break;
                            case SqlDbType.DateTime:
                                rowData[i] = SqlDateTimeToString(reader.GetDateTime(i));
                                break;
                            case SqlDbType.DateTime2:
                                rowData[i] = SqlDateTime2ToString(reader.GetDateTime(i));
                                break;
                            case SqlDbType.DateTimeOffset:
                                rowData[i] = SqlDateTimeOffsetToString(reader.GetDateTimeOffset(i));
                                break;
                            case SqlDbType.Decimal:
                                rowData[i] = reader.GetSqlDecimal(i).ToString();
                                break;
                            case SqlDbType.Float:
                                rowData[i] = reader.GetSqlDouble(i).Value.ToString("0.000000000000000E+0");
                                break;
                            case SqlDbType.Timestamp:
                            case SqlDbType.Image:
                            case SqlDbType.VarBinary:
                                rowData[i] = SqlBinaryToString(reader.GetSqlBinary(i));
                                break;
                            default:
                                rowData[i] = reader.GetValue(i).ToString();
                                break;
                        }
                    }
                }

                results.Add(rowData);
            }
            return results;
        }
开发者ID:tSQLt,项目名称:tmp,代码行数:81,代码来源:tSQLtPrivate.cs

示例3: GetPropertyValueFromReader

    private Boolean GetPropertyValueFromReader(SettingsPropertyValue spv, SqlDataReader rdr)
    {
        try
        {
            // get the ordinals of value columns, just a speed optimization issue
            Int32 PropertyValueStringOrdinal = rdr.GetOrdinal("PropertyValueString");
            Int32 PropertyValueBinaryOrdinal = rdr.GetOrdinal("PropertyValueBinary");

            // Get the value based on the SerializeAs value
            switch (spv.Property.SerializeAs)
            {
                case SettingsSerializeAs.String:
                    {
                        // If the value string is null, set property value to null
                        if (rdr.IsDBNull(PropertyValueStringOrdinal))
                        {
                            spv.PropertyValue = null;
                        }
                        else
                        {
                            // no deserialization needed, so set the PropertyValue the same as the database value, changing its type ofcourse
                            spv.PropertyValue = Convert.ChangeType(rdr.GetString(PropertyValueStringOrdinal), spv.Property.PropertyType);
                        }

                        spv.Deserialized = true;

                        break;
                    }

                case SettingsSerializeAs.Binary:
                    {
                        if (rdr.IsDBNull(PropertyValueBinaryOrdinal))
                        {
                            spv.PropertyValue = null;
                            spv.Deserialized = true;
                        }
                        else
                        {
                            spv.SerializedValue = rdr.GetSqlBinary(PropertyValueBinaryOrdinal).Value;
                            spv.Deserialized = false;
                        }

                        break;
                    }

                case SettingsSerializeAs.Xml:
                    {
                        if (rdr.IsDBNull(PropertyValueStringOrdinal))
                        {
                            spv.PropertyValue = null;
                            spv.Deserialized = true;
                        }
                        else
                        {
                            spv.SerializedValue = rdr.GetString(PropertyValueStringOrdinal);
                            spv.Deserialized = false;
                        }

                        break;
                    }
                default:
                    {
                        throw new ProviderException(
                            String.Format("Could not determine correct serialization format for profile property '{0}'.", spv.Name));
                    }
            }
        }
        catch (Exception e)
        {
            throw new ProviderException(String.Format("Error deserialising profile property '{0}'.", spv.Name), e);
        }

        // set is not dirty, we are just reading
        spv.IsDirty = false;

        return true;
    }
开发者ID:kimx,项目名称:UserProfilerLabs,代码行数:77,代码来源:SearchableSqlProfileProvider.cs

示例4: GetSqlBinaryTest

		public void GetSqlBinaryTest ()
		{
			cmd.CommandText = "Select type_binary ,10 ,convert(binary,null)";
			cmd.CommandText += "from binary_family where id=1";
			reader = cmd.ExecuteReader ();
			reader.Read ();
			// Test for standard exceptions 	
			GetMethodTests ("SqlBinary");

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

示例5: FoundTimeoutData

        private TimeoutData FoundTimeoutData(SqlDataReader dataReader)
        {
            if (dataReader.Read())
            {
                return new TimeoutData
                {
                    MessageId = dataReader.GetGuid(MessageIdIndex),
                    CorrelationId = dataReader.IsDBNull(CorrelationIdIndex) ? Guid.Empty : Guid.Parse(dataReader.GetString(CorrelationIdIndex)),
                    DestinationAddress = dataReader.GetString(DestinationIndex),
                    Expires = dataReader.GetDateTime(TimeToLiveIndex),
                    Headers = objectSerializer.DeserializeObject<Dictionary<string, string>>(dataReader.GetString(HeadersIndex)),
                    Body = dataReader.IsDBNull(BodyIndex) ? null : dataReader.GetSqlBinary(BodyIndex).Value
                };
            }

            return null;
        }
开发者ID:AdrianFreemantle,项目名称:Hermes,代码行数:17,代码来源:SqlTimeoutStorage.cs

示例6: ChannelFromDataReader

        private Channel ChannelFromDataReader(SqlDataReader rdr)
        {
            var channel = new Channel();
            channel.Id = rdr.GetInt32(rdr.GetOrdinal("Id"));
            channel.Title = rdr.GetString(rdr.GetOrdinal("Title"));
            channel.ApplicationId = rdr.GetString(rdr.GetOrdinal("ApplicationId"));
            channel.PlatformType = (PlatformType)Enum.Parse(typeof(PlatformType), rdr.GetString(rdr.GetOrdinal("PlatformType")), true);

            if (!rdr.IsDBNull(rdr.GetOrdinal("Cert")))
                channel.Cert = rdr.GetSqlBinary(rdr.GetOrdinal("Cert")).Value;
            if (!rdr.IsDBNull(rdr.GetOrdinal("CertName")))
                channel.CertName = rdr.GetString(rdr.GetOrdinal("CertName"));
            if (!rdr.IsDBNull(rdr.GetOrdinal("CertPassword")))
                channel.CertPassword = rdr.GetString(rdr.GetOrdinal("CertPassword"));

            channel.State = rdr.GetInt32(rdr.GetOrdinal("State"));

            return channel;
        }
开发者ID:xiachanghao,项目名称:SmartBoxConsole,代码行数:19,代码来源:PushBo.cs

示例7: getTableStringArray

        private static List<String[]> getTableStringArray(SqlDataReader reader, SqlString ColumnList)
        {
            DataTable schema = reader.GetSchemaTable();

            List<String[]> results = new List<string[]>();

            int numCols = schema.Rows.Count;

            if (ColumnList.ToString().Equals(""))
            {
                String[] header = new String[numCols];
                for (int i = 0; i < numCols; i++)
                {
                    DataRow row = schema.Rows[i];
                    header[i] = row["ColumnName"].ToString();
                }
                results.Add(header);
            }
            else
            {
                results.Add(ColumnList.ToString().Split(','));
            }

            while (reader.Read()) {
                String[] rowData = new String[numCols];
                for (int i = 0; i < reader.FieldCount; i++) {

                    if (reader.IsDBNull(i)) {
                        rowData[i] = NULL_STRING;
                    } else {
                        SqlDbType dbType = (SqlDbType)schema.Rows[i]["ProviderType"];

                        switch (dbType) {
                            case SqlDbType.Date:
                                rowData[i] = SqlDateToString(reader.GetDateTime(i));
                                break;
                            case SqlDbType.SmallDateTime:
                                rowData[i] = SmallDateTimeToString(reader.GetDateTime(i));
                                break;
                            case SqlDbType.DateTime:
                                rowData[i] = SqlDateTimeToString(reader.GetDateTime(i));
                                break;
                            case SqlDbType.DateTime2:
                                rowData[i] = SqlDateTime2ToString(reader.GetDateTime(i));
                                break;
                            case SqlDbType.DateTimeOffset:
                                rowData[i] = SqlDateTimeOffsetToString(reader.GetDateTimeOffset(i));
                                break;
                            case SqlDbType.Decimal:
                                rowData[i] = reader.GetSqlDecimal(i).ToString();
                                break;
                            case SqlDbType.Float:
                                rowData[i] = reader.GetSqlDouble(i).Value.ToString("0.000000000000000E+0");
                                break;
                            case SqlDbType.Timestamp:
                            case SqlDbType.Image:
                            case SqlDbType.VarBinary:
                                rowData[i] = SqlBinaryToString(reader.GetSqlBinary(i));
                                break;
                            default:
                                rowData[i] = reader.GetValue(i).ToString();
                                break;
                        }
                    }
                }

                results.Add(rowData);
            }
            return results;
        }
开发者ID:asears,项目名称:tsqlt,代码行数:70,代码来源:tSQLtPrivate.cs


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