Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL DataReader Question
Message
From
24/12/2004 20:57:30
 
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00972101
Message ID:
00972115
Views:
12
Kevin,

You *could* rename your class as Cetin suggested. Another alternative is to fully qualify the DataReader like this:
        Dim myReader As System.Data.SqlClient.SqlDataReader
~~Bonnie


>I'm new to .Net, so bear with my newby questions.
>
>I pasted this code into a Vb Module from the help file. The line
>that errors is marked below.
>
>The error is:
>"Value of type 'System.Data.SqlClient.SqlDataReader' cannot be converted to 'SQL_Examples.SQLDataReader'."
>
>
>Imports System.Data.SqlClient
>
>Public Class SQLDataReader
>
>    Public Sub ReadMyData()
>
>        Dim myConnString As String = "data source=(local);" & _
>            "initial catalog=Northwind;" & _
>            "user id=myuserid;" & _
>            "password=mypassword"
>
>        Dim mySelectQuery As String = "SELECT OrderID, CustomerID FROM Orders"
>        Dim myConnection As New SqlConnection(myConnString)
>        Dim myCommand As New SqlCommand(mySelectQuery, myConnection)
>
>        myConnection.Open()
>
>        Dim myReader As SQLDataReader
>        myReader = myCommand.ExecuteReader()   <====== ERROR IS HERE
>
>        ' Always call Read before accessing data.
>        While myReader.Read()
>            Console.WriteLine((myReader.GetInt32(0) & ", " & myReader.GetString(1)))
>        End While
>
>        ' Always call Close when done reading.
>        myReader.Close()
>
>        ' Close the connection when done with it.
>        myConnection.Close()
>
>    End Sub 'ReadMyData
>
>End Class
>
>
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Reply
Map
View

Click here to load this message in the networking platform