Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 13th, 2004, 10:57 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default da.Getint32 question

When I try to use i =da.Getint32("MemberID") I get i = -1
Memberid column in SQL Table is data type Int.

I get i = -1 whether I use da.GetValue("MemberID") or
da.item("MemberID") or da.Getint16("MemberID") or da.Getint64("MemberID").

Code I am using:


Dim da As SqlDataReader

            myConn.Open()

            da = selectCmd.ExecuteReader(CommandBehavior.SingleRow)
            da.Read()

            i = da.GetInt16("Memberid")
            Return i
            da.Close()
            myConn.Close()


What is wrong??

 
Old September 13th, 2004, 12:11 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

This from the VS help:
[Visual Basic]
Public Overridable Function GetInt64( _
   ByVal i As Integer _
) As Long Implements IDataRecord.GetInt64

The GetInt## function requires an integer as a parmeter, not a column name

That should work then

 
Old September 13th, 2004, 01:51 PM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default

jbenson001

I see what you are saying about GetInt64.
When I put s= da.Item("Name") this fetches the string that is contained in "Name" column.
How do you get the integer in "MemberID" column using data adapter in this situation??


Dim da As SqlDataReader

            myConn.Open()

            da = selectCmd.ExecuteReader(CommandBehavior.SingleRow)
            da.Read()

            i = da.GetInt16("Memberid")
            Return i
            da.Close()
            myConn.Close()


 
Old September 13th, 2004, 01:59 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Did you try:

CType(da.Item("MemberID"), Integer)

The Get functions seem to only take the index number.

Brian
 
Old September 13th, 2004, 02:33 PM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default

bmains

I tried your suggestion:

Try

            Dim da As SqlDataReader

            myConn.Open()

            da = selectCmd.ExecuteReader(CommandBehavior.SingleRow)
            da.Read()
            i = CType(da.Item("MemberID"), Integer)

            Return i
            da.Close()
            myConn.Close()

        Catch ex As Exception

            Return i = 0

        End Try


I still get -1. What does -1 mean? Does it mean i didn't return anything cuz I set the exception to 0 when it failed?

Please help me

 
Old September 14th, 2004, 11:30 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Probably... verify the query.





Similar Threads
Thread Thread Starter Forum Replies Last Post
IF question fizzerchris SQL Language 3 October 17th, 2007 10:41 PM
Question Ashwini Classic ASP Databases 2 January 5th, 2006 01:31 PM
populate data in a windows form combobox from a da anibiswas General .NET 0 March 4th, 2005 03:57 PM
I need a software development tool for building da surendran General .NET 0 February 17th, 2005 04:48 AM





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