how to check if a column in a datareader exists

”’ <summary>
”’ checks if a column in a datareader exists
”’ </summary>
”’ <param name=”reader”>SqlDataReader</param>
”’ <param name=”sColumnName”>columnname</param>
”’ <returns>true, column exists else false</returns>
”’ <remarks></remarks>
Public Function ColumnExists(ByVal reader As SqlDataReader, ByVal sColumnName As String) As Boolean
reader.GetSchemaTable().DefaultView.RowFilter = “ColumnName= ‘” + sColumnName + “‘”
Return (reader.GetSchemaTable().DefaultView.Count > 0)
End Function

..:: Whereever you go, stay in touch. Download toolbar now! It´s free, private and secure. ::..

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s