Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security
updates, and technical support.

[ Download Microsoft Edge ](https://go.microsoft.com/fwlink/p/?LinkID=2092881
) [ More info about Internet Explorer and Microsoft Edge
](https://learn.microsoft.com/en-us/lifecycle/faq/internet-explorer-microsoft-
edge)

Table of contents  Exit focus mode

Language

  *   *   *   * 

Read in English  Save  [ ](https://github.com/dotnet/dotnet-api-
docs/blob/main/xml/System.Data.SqlClient/SqlDataReader.xml "Edit This
Document")

Table of contents  Read in English  Save  [ Edit
](https://github.com/dotnet/dotnet-api-
docs/blob/main/xml/System.Data.SqlClient/SqlDataReader.xml "Edit This
Document") Print

Twitter  LinkedIn  Facebook  Email

Table of contents

#  Sql  Data  Reader.  Field  Count Property

  * Reference 

Feedback

##

##  Definition

Namespace:

     [ System.Data.SqlClient ](system.data.sqlclient?view=dotnet-plat-ext-8.0)

Assembly:

     System.Data.SqlClient.dll 

Assembly:

     System.Data.dll 

Package:

     System.Data.SqlClient v4.8.6 

Important

Some information relates to prerelease product that may be substantially
modified before itâs released. Microsoft makes no warranties, express or
implied, with respect to the information provided here.

Gets the number of columns in the current row.

    
    
    public:
     virtual property int FieldCount { int get(); };
    
    
    public:
     property int FieldCount { int get(); };
    
    
    public override int FieldCount { get; }
    
    
    public int FieldCount { get; }
    
    
    member this.FieldCount : int
    
    
    Public Overrides ReadOnly Property FieldCount As Integer
    
    
    Public ReadOnly Property FieldCount As Integer

####  Property Value

[ Int32 ](system.int32?view=dotnet-plat-ext-8.0)

When not positioned in a valid recordset, 0; otherwise the number of columns
in the current row. The default is -1.

####  Implements

[ FieldCount ](system.data.idatarecord.fieldcount?view=dotnet-plat-
ext-8.0#system-data-idatarecord-fieldcount)

####  Exceptions

[ NotSupportedException ](system.notsupportedexception?view=dotnet-plat-
ext-8.0)

There is no current connection to an instance of SQL Server.

##  Remarks

Executing a query that, by its nature, does not return rows (such as a DELETE
query), sets [ FieldCount
](system.data.sqlclient.sqldatareader.fieldcount?view=dotnet-plat-ext-8.0) to
0. However. this should not be confused with a query that returns 0 rows (such
as SELECT * FROM _table_ WHERE 1 = 2) in which case [ FieldCount
](system.data.sqlclient.sqldatareader.fieldcount?view=dotnet-plat-ext-8.0)
returns the number of columns in the table, including hidden fields. Use [
VisibleFieldCount
](system.data.sqlclient.sqldatareader.visiblefieldcount?view=dotnet-plat-
ext-8.0) to exclude hidden fields.

##  Applies to

##  See also

  * [ DataAdapters and DataReaders (ADO.NET) ](/en-us/dotnet/framework/data/adonet/dataadapters-and-datareaders)
  * [ SQL Server and ADO.NET ](/en-us/dotnet/framework/data/adonet/sql/)
  * [ ADO.NET Overview ](/en-us/dotnet/framework/data/adonet/ado-net-overview)

Collaborate with us on GitHub

The source for this content can be found on GitHub, where you can also create
and review issues and pull requests. For more information, see [ our
contributor guide ](https://learn.microsoft.com/contribute/content/dotnet/api-
documentation) .

![](https://learn.microsoft.com/media/logos/logo_net.svg)
![](https://learn.microsoft.com/media/logos/logo_net.svg)

.NET

[ Open a documentation issue  ]() [ Provide product feedback
](https://aka.ms/feedback/report?space=61)

##  Feedback

Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the
feedback mechanism for content and replacing it with a new feedback system.
For more information see: [ https://aka.ms/ContentUserFeedback
](https://aka.ms/ContentUserFeedback) .

Submit and