MedVision ad

help i have an error in vb.net (1 Viewer)

Joined
May 27, 2004
Messages
107
Gender
Male
HSC
2004
hi all im doing a web page for my major this year and im having problems with some code... the error is

Object reference not set to an instance of an object.

what is this and how do i fix it please help
 

sunny

meh.
Joined
Jul 7, 2002
Messages
5,350
Gender
Male
HSC
2002
You tried to use an object (variable) before you created it. Please post up a section of your code related to this error.
 
Joined
May 27, 2004
Messages
107
Gender
Male
HSC
2004
u see this part is in a public sub inside a public sub...


Public Sub RetrieveInfoFromDB()
Dim strSQL As String
Dim dbC As dbConnection
Dim ds As DataSet

strSQL = String.Format("SELECT access.ID, Access.LastName, Access.FirstName, Access.PhoneNum, access.access FROM Access")

ds = dbC.RecordSet(strSQL)

DataGrid1.DataSource = ds.Tables(0).DefaultView
DataGrid1.DataBind()
dbC.Close()
dbC = Nothing
End Sub
 

Winston

Active Member
Joined
Aug 30, 2002
Messages
6,128
Gender
Undisclosed
HSC
2003
Originally posted by dastonecutters
yeh datagrid1 is an actual object but the error is on

ds = dbC.RecordSet(strSQL)

are you sure RecordSet method will return a DataSet object?
 
Joined
May 27, 2004
Messages
107
Gender
Male
HSC
2004
it works when it isnt in a class and stuff i might jus leave it for my teacher cause he is the one who put it in a class
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top