Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL DataReader Question
Message
General information
Forum:
ASP.NET
Category:
Other
Title:
SQL DataReader Question
Miscellaneous
Thread ID:
00972101
Message ID:
00972101
Views:
54
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
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Next
Reply
Map
View

Click here to load this message in the networking platform