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


C# SqlDataReader.GetBytes方法代码示例

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


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

示例1: MakeDelegaciones

        /// <summary>
        /// Creates a new instance of the Delegaciones class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static DelegacionesInfo MakeDelegaciones(SqlDataReader dataReader)
        {
            DelegacionesInfo delegaciones = new DelegacionesInfo();

            if (dataReader.IsDBNull(Cod_Regional) == false)
                delegaciones.Cod_Regional = dataReader.GetInt32(Cod_Regional);
            if (dataReader.IsDBNull(Cod_Delegacion) == false)
                delegaciones.Cod_Delegacion = dataReader.GetInt32(Cod_Delegacion);
            if (dataReader.IsDBNull(Delegacion) == false)
                delegaciones.Delegacion = dataReader.GetString(Delegacion);
            if (dataReader.IsDBNull(Numero) == false)
                delegaciones.Numero = dataReader.GetString(Numero);
            if (dataReader.IsDBNull(Cod_Jefe) == false)
                delegaciones.Cod_Jefe = dataReader.GetInt32(Cod_Jefe);
            if (dataReader.IsDBNull(Email) == false)
                delegaciones.Email = dataReader.GetString(Email);
            if (dataReader.IsDBNull(LastProcess) == false)
                delegaciones.LastProcess = new Byte[Convert.ToInt32(dataReader.GetBytes(0, 0, null, 0, Int32.MaxValue))];
                dataReader.GetBytes(0, 0, delegaciones.LastProcess, 0, delegaciones.LastProcess.Length);
            if (dataReader.IsDBNull(ActualProcess) == false)
                delegaciones.ActualProcess = new Byte[Convert.ToInt32(dataReader.GetBytes(0, 0, null, 0, Int32.MaxValue))];
                dataReader.GetBytes(0, 0, delegaciones.ActualProcess, 0, delegaciones.ActualProcess.Length);
            if (dataReader.IsDBNull(TempTime) == false)
                delegaciones.TempTime = new Byte[Convert.ToInt32(dataReader.GetBytes(0, 0, null, 0, Int32.MaxValue))];
                dataReader.GetBytes(0, 0, delegaciones.TempTime, 0, delegaciones.TempTime.Length);
            if (dataReader.IsDBNull(Proc_ID) == false)
                delegaciones.Proc_ID = dataReader.GetInt32(Proc_ID);
            if (dataReader.IsDBNull(Skip) == false)
                delegaciones.Skip = dataReader.GetBoolean(Skip);
            if (dataReader.IsDBNull(SyncID) == false)
                delegaciones.SyncID = dataReader.GetGuid(SyncID);
            if (dataReader.IsDBNull(SyncTimeStamp) == false)
                delegaciones.SyncTimeStamp = DateTime.MinValue;

            return delegaciones;
        }
开发者ID:Avaruz,项目名称:Artemisa,代码行数:39,代码来源:DelegacionesDb.cs

示例2: safeGetTimestamp

 protected Timestamp safeGetTimestamp(SqlDataReader reader)
 {
     byte[] m_buffer = new byte[8];
     reader.GetBytes(reader.GetOrdinal("chTimestamp"), 0, m_buffer, 0, 8);
     return new Timestamp(m_buffer);
 }
开发者ID:eglimi,项目名称:storm,代码行数:6,代码来源:PersonMapper.cs

示例3: GetBytes_Type_Binary

		public void GetBytes_Type_Binary ()
		{
			cmd.CommandText = "Select type_binary, type_varbinary, " +
				"type_blob from binary_family where id = 1";
			reader = cmd.ExecuteReader ();
			reader.Read ();
			byte[] binary = (byte[])reader.GetValue (0);
			byte[] varbinary = (byte[])reader.GetValue (1);
			byte[] image = (byte[])reader.GetValue (2);
			reader.Close ();

			reader = cmd.ExecuteReader (CommandBehavior.SequentialAccess);
			reader.Read ();
			int len = 0;
			byte[] arr ;
			len = (int)reader.GetBytes (0,0,null,0,0);
			Assert.AreEqual (binary.Length, len, "#1");
			arr = new byte [len];
			reader.GetBytes (0,0,arr,0,len);
			for (int i=0; i<len; ++i)
				Assert.AreEqual (binary[i], arr[i], "#2");


			len = (int)reader.GetBytes (1,0,null,0,0);
			Assert.AreEqual (varbinary.Length, len, "#1");
			arr = new byte [len];
			reader.GetBytes (1,0,arr,0,len);
			for (int i=0; i<len; ++i)
				Assert.AreEqual (varbinary[i], arr[i], "#2");

			len = (int)reader.GetBytes (2,0,null,0,0);
			Assert.AreEqual (image.Length, len, "#1");
			arr = new byte [len];
			reader.GetBytes (2,0,arr,0,len);
			for (int i=0; i<len; ++i)
				Assert.AreEqual (image[i], arr[i], "#2");

			reader.Close ();

			cmd.CommandText = "Select type_binary,type_varbinary,type_blob ";
			cmd.CommandText += "from binary_family where id=1";
		
			reader = cmd.ExecuteReader (CommandBehavior.SequentialAccess);
			reader.Read ();
		
			len  = (int)reader.GetBytes (0,0,null,0,0);
			arr = new byte [100];
			for (int i=0; i<len; ++i) {
				Assert.AreEqual (len-i, reader.GetBytes (0, i, null, 0, 0), "#1_"+i);
				Assert.AreEqual (1, reader.GetBytes (0, i, arr, 0, 1), "#2_"+i);
				Assert.AreEqual (binary [i], arr [0], "#3_"+i);
			}
			Assert.AreEqual (0, reader.GetBytes (0, len+10, null, 0, 0));
			reader.Close ();
		}
开发者ID:Profit0004,项目名称:mono,代码行数:55,代码来源:SqlDataReaderTest.cs

示例4: MakeAPM

        /// <summary>
        /// Creates a new instance of the APM class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static APMInfo MakeAPM(SqlDataReader dataReader)
        {
            APMInfo aPM = new APMInfo();

            if (dataReader.IsDBNull(Cod_APM) == false)
                aPM.Cod_APM = dataReader.GetInt32(Cod_APM);
            if (dataReader.IsDBNull(Cod_Delegacion) == false)
                aPM.Cod_Delegacion = dataReader.GetInt32(Cod_Delegacion);
            if (dataReader.IsDBNull(Codigo_Completo) == false)
                aPM.Codigo_Completo = dataReader.GetString(Codigo_Completo);
            if (dataReader.IsDBNull(Numero_APM) == false)
                aPM.Numero_APM = dataReader.GetString(Numero_APM);
            if (dataReader.IsDBNull(Apellido) == false)
                aPM.Apellido = dataReader.GetString(Apellido);
            if (dataReader.IsDBNull(Nombre) == false)
                aPM.Nombre = dataReader.GetString(Nombre);
            if (dataReader.IsDBNull(Fecha_Nacimiento) == false)
                aPM.Fecha_Nacimiento = dataReader.GetDateTime(Fecha_Nacimiento);
            if (dataReader.IsDBNull(Cod_Nacionalidad) == false)
                aPM.Cod_Nacionalidad = dataReader.GetInt32(Cod_Nacionalidad);
            if (dataReader.IsDBNull(Cod_Direccion) == false)
                aPM.Cod_Direccion = dataReader.GetInt32(Cod_Direccion);
            if (dataReader.IsDBNull(Cod_Modelo) == false)
                aPM.Cod_Modelo = dataReader.GetInt32(Cod_Modelo);
            if (dataReader.IsDBNull(Fecha_Ingreso) == false)
                aPM.Fecha_Ingreso = dataReader.GetDateTime(Fecha_Ingreso);
            if (dataReader.IsDBNull(Fecha_Egreso) == false)
                aPM.Fecha_Egreso = dataReader.GetDateTime(Fecha_Egreso);
            if (dataReader.IsDBNull(Ultima_Conexion) == false)
                aPM.Ultima_Conexion = dataReader.GetDateTime(Ultima_Conexion);
            if (dataReader.IsDBNull(Ultimo_Proceso) == false)
                aPM.Ultimo_Proceso = dataReader.GetDateTime(Ultimo_Proceso);
            if (dataReader.IsDBNull(Skip) == false)
                aPM.Skip = dataReader.GetInt16(Skip);
            if (dataReader.IsDBNull(Foto) == false)
                aPM.Foto = new Byte[Convert.ToInt32(dataReader.GetBytes(0, 0, null, 0, Int32.MaxValue))];
                dataReader.GetBytes(0, 0, aPM.Foto, 0, aPM.Foto.Length);
            if (dataReader.IsDBNull(Blocking_Days) == false)
                aPM.Blocking_Days = dataReader.GetInt16(Blocking_Days);
            if (dataReader.IsDBNull(Proc_Id) == false)
                aPM.Proc_Id = dataReader.GetInt32(Proc_Id);
            if (dataReader.IsDBNull(UserName) == false)
                aPM.UserName = dataReader.GetString(UserName);
            if (dataReader.IsDBNull(Password) == false)
                aPM.Password = dataReader.GetString(Password);
            if (dataReader.IsDBNull(Email) == false)
                aPM.Email = dataReader.GetString(Email);
            if (dataReader.IsDBNull(Download) == false)
                aPM.Download = dataReader.GetDateTime(Download);
            if (dataReader.IsDBNull(External_Code) == false)
                aPM.External_Code = dataReader.GetString(External_Code);
            if (dataReader.IsDBNull(Action) == false)
                aPM.Action = dataReader.GetString(Action);
            if (dataReader.IsDBNull(Change_Del) == false)
                aPM.Change_Del = dataReader.GetBoolean(Change_Del);
            if (dataReader.IsDBNull(SyncID) == false)
                aPM.SyncID = dataReader.GetGuid(SyncID);
            if (dataReader.IsDBNull(SyncTimeStamp) == false)
                aPM.SyncTimeStamp = DateTime.MinValue;

            return aPM;
        }
开发者ID:Avaruz,项目名称:Artemisa,代码行数:65,代码来源:APMDb.cs

示例5: GetBytesTest

		public void GetBytesTest ()
		{
			cmd.CommandText = "Select type_text,type_ntext,convert(text,null) ";
			cmd.CommandText += "from string_family where id=1";
			reader = cmd.ExecuteReader ();
			reader.Read ();
			try {
				long totalsize = reader.GetBytes (0, 0, null, 0, 0);
				Assert.AreEqual (4, totalsize, "#1");
			} finally {
				reader.Close ();
			}
			
			byte[] asciiArray = (new ASCIIEncoding ()).GetBytes ("text");
			byte[] unicodeArray = (new UnicodeEncoding ()).GetBytes ("nt\u092d\u093ext");
			byte[] buffer = null ;
			long size = 0; 

			reader = cmd.ExecuteReader (CommandBehavior.SequentialAccess);
			reader.Read ();
			size = reader.GetBytes (0,0,null,0,0);
			Assert.AreEqual (asciiArray.Length, size, "#3 Data Incorrect");

			buffer = new byte[size];
			size = reader.GetBytes (0,0,buffer,0,(int)size);
			for (int i=0;i<size; i++)
				Assert.AreEqual (asciiArray[i], buffer[i], "#4 Data Incorrect");

			size = reader.GetBytes (1, 0, null, 0, 0);
			Assert.AreEqual (unicodeArray.Length, size, "#5 Data Incorrect");
			buffer = new byte[size];
			size = reader.GetBytes (1,0,buffer,0,(int)size);
			for (int i=0;i<size; i++)
				Assert.AreEqual (unicodeArray[i], buffer[i], "#6 Data Incorrect");
			
			// Test if msdotnet behavior s followed when null value 
			// is read using GetBytes 
			try {
				reader.GetBytes (2, 0, null, 0, 0);
				Assert.Fail ("#7");
			} catch (SqlNullValueException) {
			}

			try {
				reader.GetBytes (2, 0, buffer, 0, 10);
				Assert.Fail ("#8");
			} catch (SqlNullValueException) {
			}
			reader.Close ();
			// do i need to test for image/binary values also ??? 
		}
开发者ID:Profit0004,项目名称:mono,代码行数:51,代码来源:SqlDataReaderTest.cs


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