• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# SqlClient.SqlDataReader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



SqlDataReader类属于System.Data.SqlClient命名空间,在下文中一共展示了SqlDataReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: convert

        public List<List<String>> convert(SqlDataReader reader)
        {
            if (reader != null)
            {
                List<List<String>> list = new List<List<String>>();

                while (reader.Read())
                {
                    List<String> tmp = new List<String>();
                    for (int i = 0; i < reader.FieldCount; i++)
                    {
                        string s = "";
                        try
                        {
                            s = reader.GetString(i);
                        }
                        catch (SqlNullValueException)
                        {
                            s = "null";
                        }

                        tmp.Add(s);

                    }
                    list.Add(tmp);
                }
                return list;
            }
            return null;
        }
开发者ID:submarines-and,项目名称:TacoHacker999,代码行数:30,代码来源:sqlCronus.cs


示例2: Read

    public static PMSAgency Read(SqlDataReader reader)
    {
        PMSAgency retval = new PMSAgency();

        for (int i = 0; i < reader.FieldCount; i++)
        {
            switch (reader.GetName(i))
            {
                case "GroupSegment":
                    retval.Segment = Helper.ToString(reader[i]);
                    break;
                case "AType":
                    retval.ActionType = Helper.ToString(reader[i]);
                    break;
                case "Agency":
                    retval.AgencyName = Helper.ToString(reader[i]);
                    break;
                case "Market":
                    retval.Market = Helper.ToString(reader[i]);
                    break;
                case "RepGroup":
                    retval.RepGroup = Helper.ToString(reader[i]);
                    break;
               case "SiteID":
                    retval.SiteID = Helper.ToInt32(reader[i]);
                    break;
            }
        }
        return retval;
    }
开发者ID:darinel,项目名称:PSInterProdOldVersion,代码行数:30,代码来源:PMSAgencyDB.cs


示例3: SafeGetString

 /** Descripcion:
  *
  * REQ: SqlDataReader, int
  *
  * RET: static string
  */
 public static string SafeGetString(SqlDataReader reader, int colIndex)
 {
     if (!reader.IsDBNull(colIndex))
         return reader.GetString(colIndex);
     else
         return string.Empty;
 }
开发者ID:ProyInge,项目名称:ProyectoInge,代码行数:13,代码来源:ControladoraBDProyecto.cs


示例4: HashSum

 public HashSum(SqlDataReader reader, String secret = "PZS")
 {
     DataTable dt = new DataTable();
     dt.Load(reader);
     dt.TableName = secret;
     this.dt = dt;
 }
开发者ID:DrBrown3,项目名称:SQL_Exec,代码行数:7,代码来源:HashSum.cs


示例5: CloseCommand

 public bool CloseCommand()
 {
     bool flag = true;
     try
     {
         if (connection != null)
         {
             if (sqlReader != null)
             {
                 sqlReader.Close();
                 sqlReader.Dispose();
                 sqlReader = (SqlDataReader)null;
             }
             if (sqlCommand != null)
             {
                 sqlCommand.Dispose();
                 sqlCommand = (SqlCommand)null;
             }
         }
     }
     catch (Exception ex)
     {
         flag = false;
         hasError = true;
         errorMessage = "Database command error : " + ex.Message;
     }
     return flag;
 }
开发者ID:GlxSeg,项目名称:SEGClone,代码行数:28,代码来源:SqlHelper.cs


示例6: SqlCachedBuffer

 internal SqlCachedBuffer(SqlDataReader dataRdr, int columnOrdinal, long startPosition)
 {
     int num;
     this._cachedBytes = new ArrayList();
     long dataIndex = startPosition;
     do
     {
         byte[] buffer = new byte[0x800];
         num = (int) dataRdr.GetBytesInternal(columnOrdinal, dataIndex, buffer, 0, 0x800);
         dataIndex += num;
         if (this._cachedBytes.Count == 0)
         {
             this.AddByteOrderMark(buffer, num);
         }
         if (0 < num)
         {
             if (num < buffer.Length)
             {
                 byte[] dst = new byte[num];
                 Buffer.BlockCopy(buffer, 0, dst, 0, num);
                 buffer = dst;
             }
             this._cachedBytes.Add(buffer);
         }
     }
     while (0 < num);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:SqlCachedBuffer.cs


示例7: LoadFromDataReader

        /// <summary>
        /// Loads the entity from a <b>SqlDataReader</b> object.
        /// </summary>
        /// <param name="dr">The data reader to read from.</param>
        /// <returns>Returns the number of columns read.</returns>
        /// <remarks>
        /// Always reads at the current cursor position, doesn't calls the <b>Read</b> function
        /// on the <b>SqlDataReader</b> object. Reads data columns by their ordinal position in
        /// the query and not by their names.
        /// </remarks>
        internal override int LoadFromDataReader(SqlDataReader dr)
        {
            int o = base.LoadFromDataReader(dr);

            ++o;    // skip guid
            this.workflowTypeName = dr.GetString(++o);
            this.dateStarted = dr.IsDBNull(++o) ? DateTime.MinValue : dr.GetDateTime(o);
            this.dateFinished = dr.IsDBNull(++o) ? DateTime.MinValue : dr.GetDateTime(o);
            this.jobExecutionStatus = (JobExecutionState)dr.GetInt32(++o);
            this.suspendTimeout = dr.IsDBNull(++o) ? DateTime.MinValue : dr.GetDateTime(o);
            this.scheduleType = (ScheduleType)dr.GetInt32(++o);
            this.scheduleTime = dr.IsDBNull(++o) ? DateTime.MinValue : dr.GetDateTime(o);
            this.recurringPeriod = (RecurringPeriod)dr.GetInt32(++o);
            this.recurringInterval = dr.GetInt32(++o);
            this.recurringMask = dr.GetInt64(++o);
            this.workflowInstanceId = dr.IsDBNull(++o) ? Guid.Empty : dr.GetGuid(o);
            this.adminRequestTime = dr.IsDBNull(++o) ? DateTime.MinValue : dr.GetDateTime(o);
            if (!dr.IsDBNull(++o))
            {
                XmlSerializer ser = new XmlSerializer(typeof(JobAdminRequestData));
                StringReader sr = new StringReader(dr.GetString(o));
                this.adminRequestData = (JobAdminRequestData)ser.Deserialize(sr);
            }
            else
            {
                this.adminRequestData = null;
            }
            this.adminRequestResult = dr.GetInt32(++o);
            this.exceptionMessage = dr.IsDBNull(++o) ? null : dr.GetString(o);

            return o;
        }
开发者ID:horvatferi,项目名称:graywulf,代码行数:42,代码来源:JobInstance.io.cs


示例8: ChiTietPhieuXuatKho

 public ChiTietPhieuXuatKho(SqlDataReader dataReader)
 {
     PhieuXuatKhoGuid = dataReader["PhieuXuatKhoGuid"] != null ? (Guid)dataReader["PhieuXuatKhoGuid"] : Guid.Empty;
     ItemStoreGuid = dataReader["ItemStoreGuid"] != null ? (Guid)dataReader["ItemStoreGuid"] : Guid.Empty;
     HoaDonBanHangGuid = dataReader["HoaDonBanHangGuid"] != null ? (Guid)dataReader["HoaDonBanHangGuid"] : Guid.Empty;
     SoLuong = dataReader["SoLuong"] != null ? (Int32)dataReader["SoLuong"] : 0;
 }
开发者ID:enjoyvinh,项目名称:project-hutech,代码行数:7,代码来源:ChiTietPhieuXuatKho.cs


示例9: MakeViewAuditoriaListaVerificacionDetalleCross

        /// <summary>
        /// Creates a new instance of the ViewAuditoriaListaVerificacionDetalleCross class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static ViewAuditoriaListaVerificacionDetalleCrossInfo MakeViewAuditoriaListaVerificacionDetalleCross(SqlDataReader dataReader)
        {
            ViewAuditoriaListaVerificacionDetalleCrossInfo viewAuditoriaListaVerificacionDetalleCross = new ViewAuditoriaListaVerificacionDetalleCrossInfo();

            if (dataReader.IsDBNull(AuditoriaListaVerificacionDetalleCargoId) == false)
                viewAuditoriaListaVerificacionDetalleCross.AuditoriaListaVerificacionDetalleCargoId = dataReader.GetInt32(AuditoriaListaVerificacionDetalleCargoId);
            if (dataReader.IsDBNull(AuditoriaListaVerificacionDetalleId) == false)
                viewAuditoriaListaVerificacionDetalleCross.AuditoriaListaVerificacionDetalleId = dataReader.GetInt32(AuditoriaListaVerificacionDetalleId);
            if (dataReader.IsDBNull(AuditoriaListaVerificacionId) == false)
                viewAuditoriaListaVerificacionDetalleCross.AuditoriaListaVerificacionId = dataReader.GetInt32(AuditoriaListaVerificacionId);
            if (dataReader.IsDBNull(CargoId) == false)
                viewAuditoriaListaVerificacionDetalleCross.CargoId = dataReader.GetInt32(CargoId);
            if (dataReader.IsDBNull(Cargo) == false)
                viewAuditoriaListaVerificacionDetalleCross.Cargo = dataReader.GetString(Cargo);
            if (dataReader.IsDBNull(Activo) == false)
                viewAuditoriaListaVerificacionDetalleCross.Activo = dataReader.GetBoolean(Activo);
            if (dataReader.IsDBNull(AuditoriaPunto) == false)
                viewAuditoriaListaVerificacionDetalleCross.AuditoriaPunto = dataReader.GetString(AuditoriaPunto);
            if (dataReader.IsDBNull(AuditoriaControl) == false)
                viewAuditoriaListaVerificacionDetalleCross.AuditoriaControl = dataReader.GetString(AuditoriaControl);
            if (dataReader.IsDBNull(PuntajeRequerido) == false)
                viewAuditoriaListaVerificacionDetalleCross.PuntajeRequerido = dataReader.GetDecimal(PuntajeRequerido);
            if (dataReader.IsDBNull(Empresa) == false)
                viewAuditoriaListaVerificacionDetalleCross.Empresa = dataReader.GetString(Empresa);
            if (dataReader.IsDBNull(Orden) == false)
                viewAuditoriaListaVerificacionDetalleCross.Orden = dataReader.GetByte(Orden);

            return viewAuditoriaListaVerificacionDetalleCross;
        }
开发者ID:Avaruz,项目名称:SGC,代码行数:32,代码来源:ViewAuditoriaListaVerificacionDetalleCrossDb.cs


示例10: MakeViewSeguridadUsuario

        /// <summary>
        /// Creates a new instance of the ViewSeguridadUsuario class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static ViewSeguridadUsuarioInfo MakeViewSeguridadUsuario(SqlDataReader dataReader)
        {
            ViewSeguridadUsuarioInfo viewSeguridadUsuario = new ViewSeguridadUsuarioInfo();

            if (dataReader.IsDBNull(SeguridadUsuarioId) == false)
                viewSeguridadUsuario.SeguridadUsuarioId = dataReader.GetInt32(SeguridadUsuarioId);
            if (dataReader.IsDBNull(SeguridadRolId) == false)
                viewSeguridadUsuario.SeguridadRolId = dataReader.GetInt32(SeguridadRolId);
            if (dataReader.IsDBNull(Rol) == false)
                viewSeguridadUsuario.Rol = dataReader.GetString(Rol);
            if (dataReader.IsDBNull(NombreUsuario) == false)
                viewSeguridadUsuario.NombreUsuario = dataReader.GetString(NombreUsuario);
            if (dataReader.IsDBNull(Nombres) == false)
                viewSeguridadUsuario.Nombres = dataReader.GetString(Nombres);
            if (dataReader.IsDBNull(Apellidos) == false)
                viewSeguridadUsuario.Apellidos = dataReader.GetString(Apellidos);
            if (dataReader.IsDBNull(PaswordHash) == false)
                viewSeguridadUsuario.PaswordHash = dataReader.GetString(PaswordHash);
            if (dataReader.IsDBNull(Salt) == false)
                viewSeguridadUsuario.salt = dataReader.GetString(Salt);
            if (dataReader.IsDBNull(Activo) == false)
                viewSeguridadUsuario.Activo = dataReader.GetBoolean(Activo);
            if (dataReader.IsDBNull(NombreCompleto) == false)
                viewSeguridadUsuario.NombreCompleto = dataReader.GetString(NombreCompleto);

            return viewSeguridadUsuario;
        }
开发者ID:Avaruz,项目名称:SGC,代码行数:30,代码来源:ViewSeguridadUsuarioDb.cs


示例11: GetTemplate

        public Template GetTemplate(SqlDataReader reader)
        {
            var htmlTemplate = reader["Template"].ToString();
            var name = reader["Name"].ToString();

            return new Template(name, htmlTemplate);
        }
开发者ID:Confirmit,项目名称:Students,代码行数:7,代码来源:TemplateProvider.cs


示例12: CustomTheme

    } // End of the constructor

    /// <summary>
    /// Create a new custom theme from a reader
    /// </summary>
    /// <param name="reader"></param>
    public CustomTheme(SqlDataReader reader)
    {
        // Set values for instance variables
        this.id = Convert.ToInt32(reader["id"]);
        this.name = reader["name"].ToString();

    } // End of the constructor
开发者ID:raphaelivo,项目名称:a-webshop,代码行数:13,代码来源:CustomTheme.cs


示例13: Cargar

 public ObjetoDominio Cargar(long id, SqlDataReader filas)
 {
     string titulo = (string)filas["Titulo"];
     Album resultado = new Album(id, titulo);
     CargarCanciones(resultado, filas);
     return resultado;
 }
开发者ID:huang-lu,项目名称:PoEAA,代码行数:7,代码来源:AlbumMapper.cs


示例14: SafeGetInt32

 /** Descripcion:
  *
  * REQ: SqlDataReader,int
  *
  * RET: static int
  */
 public static int SafeGetInt32(SqlDataReader reader, int colIndex)
 {
     if (!reader.IsDBNull(colIndex))
         return reader.GetInt32(colIndex);
     else
         return -1;
 }
开发者ID:ProyInge,项目名称:ProyectoInge,代码行数:13,代码来源:ControladoraBDProyecto.cs


示例15: BaseFlowerLinkRaceRank

    public BaseFlowerLinkRaceRank(SqlDataReader reader)
    {
        if(reader ==null)
            throw new Exception();

        this.InitData(reader);
    }
开发者ID:rongxiong,项目名称:Scut,代码行数:7,代码来源:BaseFlowerLinkRaceRank.cs


示例16: CheckSalesPersonLogIn

 // CHECK IF SALES PERSON EXIST IN DATBASE
 public static string CheckSalesPersonLogIn(SqlDataReader dr)
 {
     bool noExist = true;
     bool isActive = true;
     string clear = null;
     while (dr.Read())
     {
         clear = dr.GetString(0);
         isActive = dr.GetBoolean(5);
         noExist = false;
     }
     if (!isActive)
     {
         MessageBox.Show("Sorry, you are fired!", "LOL", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return null;
     }
     else if (noExist)
     {
         MessageBox.Show("Not in the register.", "Unregistered Sales Person", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return null;
     }
     else
     {
         return clear;
     }
 }
开发者ID:JoelPennegard,项目名称:sysa14affairs,代码行数:27,代码来源:Utility.cs


示例17: fillData

 public override void fillData(SqlDataReader reader)
 {
     drivinglicence = (string)reader.GetValue(0);
     drivinglicencetype = (string)reader.GetValue(1);
     point = (int)reader.GetValue(2);
     ID = (string)reader.GetValue(3);
 }
开发者ID:gtx1049,项目名称:DataBaseCurseDesign,代码行数:7,代码来源:Carmanager.cs


示例18: readTable

        public static List<Club> readTable(string SqlQuery, string serverName, string databaseName)
        {
            myConnection = new SqlConnection(serverName + ";" + databaseName + ";" + "Integrated Security=true");

            try
            {
                myConnection.Open();
                myCommand = new SqlCommand(SqlQuery, myConnection);
                myReader = myCommand.ExecuteReader();
                ClubList.Clear();
                while(myReader.Read()) {
                    //Console.WriteLine(myReader[0].ToString());
                    //code here to map query output to club objects and put into list
                    ClubList.Add(new Club
                    {
                        id = myReader[0].ToString(),
                        //name = myReader[1].ToString(),
                        //address = myReader[2].ToString(),
                        //city = myReader[3].ToString(),
                        //state = myReader[4].ToString()
                    });
                }
            } catch (Exception e) {
                Console.WriteLine(e.ToString());
            }
            finally
            {
                myConnection.Close();
            }
            return ClubList;
        }
开发者ID:mashhype,项目名称:APIParsers,代码行数:31,代码来源:DBMethods.cs


示例19: loadlist

        // Apresentar os registros da pesquisa desejada.
        public void loadlist()
        {
            listBox1.Items.Clear();
            listBox2.Items.Clear();
            listBox3.Items.Clear();
            listBox4.Items.Clear();
            listBox5.Items.Clear();
            listBox6.Items.Clear();
            listBox7.Items.Clear();

            conexao.Open();
            comando.CommandText = "SELECT * FROM Contatos";
            LerDados = comando.ExecuteReader();
            if (LerDados.HasRows)
            {
                while (LerDados.Read())
                {
                    listBox1.Items.Add(LerDados[0].ToString());
                    listBox2.Items.Add(LerDados[1].ToString());
                    listBox3.Items.Add(LerDados[2].ToString());
                    listBox4.Items.Add(LerDados[3].ToString());
                    listBox5.Items.Add(LerDados[4].ToString());
                    listBox6.Items.Add(LerDados[5].ToString());
                    listBox7.Items.Add(LerDados[6].ToString());

                }
            }
            conexao.Close();
        }
开发者ID:LuizGiovaniJoao,项目名称:AgendaEletronica1.0,代码行数:30,代码来源:Pesquisa.cs


示例20: cbo

        private void cbo()
        {
            sb = new StringBuilder();
            sb.Remove(0, sb.Length);
            sb.Append("SELECT SupplierId,SupplierName FROM SUPPLIER;");
            sb.Append("SELECT UserId,UserName FROM UserLogin;");

            string sqlIni = sb.ToString();
            com = new SqlCommand();
            com.CommandText = sqlIni;
            com.CommandType = CommandType.Text;
            com.Connection = Conn;
            dr = com.ExecuteReader();

            if (dr.HasRows)
            {
                //supplier
                DataTable dtSupplier = new DataTable();
                dtSupplier.Load(dr);
                cboSupplier.BeginUpdate();
                cboSupplier.DisplayMember = "SupplierName";
                cboSupplier.ValueMember = "SupplierId";
                cboSupplier.DataSource = dtSupplier;
                cboSupplier.EndUpdate();
                //User
                DataTable dtUserId = new DataTable();
                dtUserId.Load(dr);
                cboUserId.BeginUpdate();
                cboUserId.DisplayMember = "UserName";
                cboUserId.ValueMember = "UserId";
                cboUserId.DataSource = dtUserId;
                cboUserId.EndUpdate();

            }
        }
开发者ID:itktc,项目名称:projectktc-v2,代码行数:35,代码来源:frmUpdateBidCancle.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SqlClient.SqlDependency类代码示例发布时间:2022-05-26
下一篇:
C# SqlClient.SqlDataAdapter类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap