i just new to aspx.net
i try to call array variable from aspx.vb but problem occured
Object reference not set to an instance of an object.
here the code in aspx.vb :
Imports System.Data.OleDb
Partial Class MasterPage Inherits System.Web.UI.MasterPage
Public count() As String
Public Location() As String
Public m As Integer = 1
Public i As Integer = 1
Public Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim connectString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("db1.mdb")
Dim cn As OleDbConnection = New OleDbConnection(connectString)
cn.Open()
Dim selectString As String = "SELECT * FROM Landslides"
Dim cmd As OleDbCommand = New OleDbCommand(selectString, cn)
Dim reader As OleDbDataReader = cmd.ExecuteReader()
While (reader.Read())
count(m) = reader("Bil").ToString
Location(m) = reader("Location").ToString
m += 1
End While
End Sub
code on aspx :
<% For i = 1 To m Step 1 %>
<li><br /><a href='Second.aspx?id='> <%Response.Write(Location(m))%> </a></li>
<%Next%>
when i try to compile result is fine . but when i try to load the website there will be error . i am using visual studio 2005