Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim MyConnection As SqlConnection
Dim MyCommand As SqlCommand
Dim MyReader As SqlDataReader
MyConnection = New SqlConnection()
MyConnection.ConnectionString = _
ConfigurationManager.ConnectionStrings("SQLOLEDB.apxcs3.apsu.edu.wharper1").ConnectionString
MyCommand = New SqlCommand()
MyCommand.CommandText = "SELECT TOP 1 * FROM VISITS"
MyCommand.CommandType = CommandType.Text
MyCommand.Connection = MyConnection
MyCommand.Connection.Open()
MyReader = MyCommand.ExecuteReader(Commandbehavior.CloseConnection)
dvVisits.DataSource = MyReader
dvVisits.DataBind()
MyCommand.Dispose()
MyCommand.Connection.Dispose()
End IfImports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim MyConnection As SqlConnection
Dim MyCommand As SqlCommand
Dim MyReader As SqlDataReader
MyConnection = New SqlConnection()
MyConnection.ConnectionString = _
ConfigurationManager.ConnectionStrings("SQLOLEDB.apxcs3.apsu.edu.wharper1").ConnectionString
MyCommand = New SqlCommand()
MyCommand.CommandText = "SELECT TOP 1 * FROM VISITS"
MyCommand.CommandType = CommandType.Text
MyCommand.Connection = MyConnection
MyCommand.Connection.Open()
MyReader = MyCommand.ExecuteReader(Commandbehavior.CloseConnection)
dvVisits.DataSource = MyReader
dvVisits.DataBind()
MyCommand.Dispose()
MyCommand.Connection.Dispose()
End If
↧
Error states: Object reference not set to an instance of an object
↧