Wrox Programmer Forums
|
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
 
Old September 26th, 2010, 08:55 AM
Friend of Wrox
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile 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.
 
Old September 26th, 2010, 09:00 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old September 26th, 2010, 09:04 AM
Friend of Wrox
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile

Thanks Imar...
 
Old September 30th, 2010, 08:02 AM
Friend of Wrox
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile

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?
 
Old September 30th, 2010, 08:18 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old October 1st, 2010, 09:09 AM
Friend of Wrox
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile

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)?
 
Old October 1st, 2010, 12:43 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old October 2nd, 2010, 03:10 AM
Registered User
 
Join Date: Oct 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question datatype

there is how many datatype c# support..?
 
Old October 2nd, 2010, 09:23 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.