 |
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
 | This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

September 26th, 2010, 08:55 AM
|
Friend of Wrox
|
|
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
|
|
Data Types
Hi Imar,
I am trying to get the values of data type smallint and bigint in the Business Logic Layer using the following code,
Code:
Using myReader As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
If myReader.Read() Then
Dim test As Short = myReader.GetShort(myReader.GetOrdinal("CategoryId"))
theProduct = New Product(myReader.GetLong(myReader.GetOrdinal("Id")), myReader.GetShort(myReader.GetOrdinal("CategoryId")))
theProduct.Name = myReader.GetString(myReader.GetOrdinal("Name"))
rest code goes hereâ¦â¦..
End Using
But problem is that I do not see any method GetShort & GetLong for the smallint and bigint data types respectively.
So is there any other method to cast these two variables in their respected types?
Thanks.
|

September 26th, 2010, 09:00 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Shorts and Longs are language specific aliases for the System.Int16 and System.Int64 types.... You'll find Get* methods for these on the SqlDataReader.
Imar
|

September 26th, 2010, 09:04 AM
|
Friend of Wrox
|
|
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
|
|
Thanks Imar...
|

September 30th, 2010, 08:02 AM
|
Friend of Wrox
|
|
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
|
|
Hi,
I am not getting any such Get methods which refer to Shorts & Longs.
Code:
Using myReader As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
If myReader.Read() Then
Dim test As Short = myReader.GetShort(myReader.GetOrdinal("CategoryId"))
theProduct = New Product(myReader.GetLong(myReader.GetOrdinal("Id")), myReader.GetShort(myReader.GetOrdinal("CategoryId")))
theProduct.Name = myReader.GetString(myReader.GetOrdinal("Name"))
rest code goes hereâ¦â¦..
End Using
What are these 2 methods?
|

September 30th, 2010, 08:18 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Isn't that in my previous answer???
Quote:
Shorts and Longs are language specific aliases for the System.Int16 and System.Int64 types.... You'll find Get* methods for these on the SqlDataReader.
|
Imar
|

October 1st, 2010, 09:09 AM
|
Friend of Wrox
|
|
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
|
|
Hi Imar,
This time I am not getting you. What do you mean by Get*? If you are saying GetInt32, GetByte, GetString etc. collectively as Get* then I do not see any Get method for Shorts & Longs.
What are the exact methods for referencing the two (Shorts & Longs)?
|

October 1st, 2010, 12:43 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
I am not sure why you don't get this and what's not clear in my previous posts, so I'll be as specirfic as possible:
Quote:
Shorts and Longs are language specific aliases for the System.Int16 and System.Int64 types
|
In other words, Shorts and Longs only exist in VB; they don't exist in .NET. In .NET their equivalents are System.Int16 and System.Int64.
The DataReader is a .NET type, so it's not aware of language specific types such as long. Instead, it's designed to work with System.Int16 and System.Int64 types. So, what happens when you look at the list of methods supported by the DataReader and see if you can find a GetInt16 or a GetInt64?
Imar
|

October 2nd, 2010, 03:10 AM
|
Registered User
|
|
Join Date: Oct 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
datatype
there is how many datatype c# support..?
|

October 2nd, 2010, 09:23 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Enough? 42 maybe? I don't know as I don't understand the question.
Did you figure out how to read longs and shorts?
Imar
|
Similar Threads
|
Thread |
Thread Starter |
Forum |
Replies |
Last Post |
Data Types |
Clive Astley |
Access |
1 |
January 17th, 2006 04:13 PM |
Data Types |
edward2006 |
Infopath |
0 |
November 7th, 2005 06:06 PM |
Data types in SQL |
SQ |
SQL Language |
4 |
October 3rd, 2004 02:07 AM |
Data Types |
bph |
Access VBA |
3 |
January 25th, 2004 05:50 PM |
|
 |