Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL DataReader Question
Message
De
24/12/2004 19:30:29
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00972101
Message ID:
00972109
Vues:
20
>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
>
>
Kevin,
Your class name is SQLDataReader. Your namespace I think is SQL_Examples. Rename your class.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform