Results 1 to 3 of 3

Thread: Program creating class using SQLDataReader [Resolved]

  1. #1

    Thread Starter
    Addicted Member Porsche944's Avatar
    Join Date
    Apr 2005
    Location
    Ann Arbor
    Posts
    182

    Resolved Program creating class using SQLDataReader [Resolved]

    Hey Guys,
    I am trying to create a class that makes use of the SQL DataReader but I keep getting this error:

    'system.data.sqlclient.sqldatareader.private sub new(command as system.data.sqlclient.sqlcommand') is not accessibe in this context becase it is 'private'

    Here is the declarations for my class where I am getting this error the line in question is
    dim mySQLRead as new SqlDataReader

    Code:
    Public Class SQLDatabase
        Dim mySQLConnection As New SQLConnection
        Dim mySQLCommand As New SQLCommand
        Dim mySQLDataAdpater As New SqlDataAdapter
        Dim mySQLRead As New SqlDataReader
    End Class
    Last edited by Porsche944; Apr 28th, 2005 at 07:20 AM.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Program creating class using SQLDataReader

    That's because you are attempting to create an instance of the data reader, and in order to do so, you have to pass it the command object.

    There is no option to create new SQLDataReader w/o any parameters.

    Try just Dim mySQLRead as SQLDataReader, only create a new instance once you are actualy ready for it.


    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Addicted Member Porsche944's Avatar
    Join Date
    Apr 2005
    Location
    Ann Arbor
    Posts
    182

    Resolved Re: Program creating class using SQLDataReader [resolved]

    That worked thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width