object not set to an instance of the object

Dim thisConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\Bluefin\SellYourHouse\SellYourHouse.mdb; uid=admin; pass=;"
Dim thisConn As New OleDbConnection(thisConnectionString)

Private Function ConnectToDatabase() As Boolean
Try
thisConn.Open()
Catch ex As Exception
lblHouseError.Text = ex.Message
lblHouseError.Visible = True
End Try
End Function

Private Function DisconnectFromDatabase() As Boolean
Try
thisConn.Close()
Catch ex As Exception
lblHouseError.Text = ex.Message
lblHouseError.Visible = True
End Try
End Function

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MyBase.PageName = "SellYour-House.Com - List Of Houses"

oHeader = CType(LoadControl("TopMenu.ascx"), TopMenu)
oHeader.EnableViewState = False
oHeader.createMenu()
oBody = CType(LoadControl("ctrlHouseList.ascx"), ctrlHouseList)
oBody.EnableViewState = False
If Not Page.IsPostBack Then
getTop()
ListHouses()
End If

End Sub

Private Sub getTop()
phHeader.Controls.Add(oHeader)
oHeader = Nothing
End Sub

Private Sub ListHouses()
'-- Add the quote items --

Dim pobjReader As OleDb.OleDbDataReader
Dim piHouseItemId As Integer
Dim strAddress As String
Dim strPostCode As String
Dim strCountry As String
Dim strPrice As String
Dim strDescription As String
Dim strImageRef As String
Try
Dim thisOleDbCommand As OleDb.OleDbCommand
ConnectToDatabase()
'thisOleDbCommand
'
thisOleDbCommand.CommandText = "Select HouseOwner.ID, House.Address, House.Postcode, House.Country, House.Price, " & _
"House.Description, HouseOwner.Image From House inner join HouseOwner on House.ID" & _
" = HouseOwner.HouseID"
thisOleDbCommand.Connection = thisConn

pobjReader = thisOleDbCommand.ExecuteReader

Do While pobjReader.Read

oBody = CType(LoadControl("ctrlHouseList.ascx"), ctrlHouseList)
oBody.EnableViewState = False

piHouseItemId = CType(pobjReader("ID"), Integer)
strAddress = CType(pobjReader("Address"), String)
strPostCode = CType(pobjReader("Postcode"), String)
strCountry = CType(pobjReader("Country"), String)
strPrice = "?quot; & CType(pobjReader("Price"), String)
strDescription = CType(pobjReader("Description"), String)
strImageRef = CType(pobjReader("Image"), String)
oBody.ID = CType(piHouseItemId, String)

oBody.InitialiseItem(strAddress, strPostCode, strCountry, strPrice, strDescription, strImageRef)

phBody.Controls.Add(oBody)

oBody = Nothing

Loop

Catch ex As Exception

lblHouseError.Text = ex.Message
lblHouseError.Visible = True

Finally

DisconnectFromDatabase()

End Try

End Sub

___________________________________________

Stepped through it and it happens at the

Dim thisConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\Bluefin\SellYourHouse\SellYourHouse.mdb; uid=admin; pass=;"
Dim thisConn As New OleDbConnection(thisConnectionString)

but in the server explorer tab its able to show all the tables i'm connecting to in the database

Any help much appreciated
 
Back
Top