p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

aspx thread: Returning DataType and Length of a Column


Message #1 by "Hugh McLaughlin" <hugh@k...> on Wed, 31 Jul 2002 21:36:11
Hello Everyone and thanks for your help in advance.  I am working on an 
application that returns the name of a column in SQL Server table.  The 
code looks like this:

	For MyCounter = 1 To (MyFieldCount-1)

		ColumnName=myReader.GetName(MyCounter)
		
	Next

However, I also need to return the DataType and Length of the column as 
well.  I tried the syntax:

ColumnType=MyReader.DataType(MyCounter)

but it throws a syntax error.  I am not sure how to do this.  Any help 
would be greatly appreciated.  Thanks.
Message #2 by "David Adames" <david@p...> on Wed, 31 Jul 2002 18:04:39 -0400
Hugh,

I think I have used one of these...

y = myReader.GetDataTypeName(iCol).ToString
or 
y = myReader.GetFieldType(iCol).ToString()

As far as length of column I don't know.

David X



-----Original Message-----
From: Hugh McLaughlin [mailto:hugh@k...]
Sent: Wednesday, July 31, 2002 9:36 PM
To: ASP+
Subject: [aspx] Returning DataType and Length of a Column


Hello Everyone and thanks for your help in advance.  I am working on an 
application that returns the name of a column in SQL Server table.  The 
code looks like this:

	For MyCounter = 1 To (MyFieldCount-1)

		ColumnName=myReader.GetName(MyCounter)
		
	Next

However, I also need to return the DataType and Length of the column as 
well.  I tried the syntax:

ColumnType=MyReader.DataType(MyCounter)

but it throws a syntax error.  I am not sure how to do this.  Any help 
would be greatly appreciated.  Thanks.
Message #3 by "David Adames" <david@p...> on Wed, 31 Jul 2002 18:12:37 -0400
See also

SqlDataReader.GetSchemaTable Method

The GetSchemaTable method returns metadata about each column incl...
ColumnName
DataType
ColumnSize
etc.

-----Original Message-----
From: Hugh McLaughlin [mailto:hugh@k...]
Sent: Wednesday, July 31, 2002 9:36 PM
To: ASP+
Subject: [aspx] Returning DataType and Length of a Column


Hello Everyone and thanks for your help in advance.  I am working on an 
application that returns the name of a column in SQL Server table.  The 
code looks like this:

	For MyCounter = 1 To (MyFieldCount-1)

		ColumnName=myReader.GetName(MyCounter)
		
	Next

However, I also need to return the DataType and Length of the column as 
well.  I tried the syntax:

ColumnType=MyReader.DataType(MyCounter)

but it throws a syntax error.  I am not sure how to do this.  Any help 
would be greatly appreciated.  Thanks.

  Return to Index