Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET 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 March 21st, 2006, 11:03 AM
Registered User
Join Date: Mar 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Datareader problem, killing me

when i try to read my datareader it always returns null. please help.

Here is my code

    Dim SQL As String
    Dim varresult As String

        SQL = "<editied out>" 'the sql string works. returns a record when ran manually.

    Dim objConn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrin gs("strConnection").ConnectionString)
    Dim command3 As SqlCommand = New SqlCommand(Sql, objConn)

    Dim dr As SqlDataReader = command3.ExecuteReader()

    If Not (dr Is Nothing) Then
        Do While dr.Read
            varresult = dr("SettingValue").ToString
    End If


Old March 23rd, 2006, 06:44 PM
Registered User
Join Date: Mar 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts

Maybe this help you
[ MSDN rocks! :) ]
------------------ cut here -------------------------------------
Public Sub CreateMySqlDataReader(mySelectQuery As String, _
myConnectionString As String)
    Dim myConnection As New SqlConnection(myConnectionString)
    Dim myCommand As New SqlCommand(mySelectQuery, myConnection)
    Dim myReader As SqlDataReader =
myCommand.ExecuteReader(CommandBehavior.CloseConne ction)
    While myReader.Read()
    End While
    'Implicitly closes the connection because
CommandBehavior.CloseConnection was specified.
 End Sub
------------------ cut here -------------------------------------

Similar Threads
Thread Thread Starter Forum Replies Last Post
DataReader Problem gaurav_jain2403 ADO.NET 5 October 10th, 2007 03:48 PM
Problem with CPU time in killing process Samatha General .NET 0 December 14th, 2006 06:37 AM
Datareader problem is about to cause my death joer80 .NET Framework 2.0 1 June 7th, 2006 07:20 AM
DataReader problem nalla ASP.NET 1.0 and 1.1 Professional 6 February 7th, 2006 06:07 AM
Problem with datareader ashokparchuri ADO.NET 2 May 13th, 2005 04:32 AM

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