Hi All,



I have an intermittent problem with an SQLDataAdapter.Fill command. Every
now and then the system returns an "Object reference not set to an instance
of an object" right after filling the Address table.



Public Sub GetProfileTables(ByVal strSQL As String)


Dim cnn As New SqlConnection("Server=localhost; Database=myDatabase;
UID=user; PWD=password;")

_profileSet = New DataSet("Profile")
cnn.Open()



'Get the profile tables information

' The SQL statement would be something like SELECT * FROM vwProfile
WHERE profile_key = 1110201

' where the profile key basically is different depending on the
record being viewed.

Dim daProfile As New SqlDataAdapter(strSQL, cnn)
daProfile.Fill(_profileSet, "Profile")
_profileView = _profileSet.Tables("Profile").DefaultView



'Get the profile addresses
strSQL = "select * from address where profile_key = " &
_profileView(0)("profile_key")
daProfile.SelectCommand = New SqlCommand(strSQL, cnn)
daProfile.Fill(_profileSet, "Address")



'Define the parent and child columns
Dim parentCol, childCol As DataColumn
parentCol = _profileSet.Tables("Profile").Columns("profile_key")
childCol = _profileSet.Tables("Address").Columns("profile_key") '
**THIS IS WHERE THE ERROR OCCURS**



'Define the relationship of the data
Dim drProfile As DataRelation
drProfile = New DataRelation("ProfileAddress", parentCol, childCol)
_profileSet.Relations.Add(drProfile)



cnnITT.Close()
End Sub



Any suggestions?



Thanks

Ryan

Re: Object reference not set to an instance of an object by Rajesh

Rajesh
Wed Mar 03 19:51:14 CST 2004

can you check whether your fill command add "address" datatable into
_profileset dataset?

Regards,

Rajesh Patel

"Yogs" <ryan@NOSPAMjagdfeld.com> wrote in message
news:OzV3S4VAEHA.1456@TK2MSFTNGP09.phx.gbl...
> Hi All,
>
>
>
> I have an intermittent problem with an SQLDataAdapter.Fill command. Every
> now and then the system returns an "Object reference not set to an
instance
> of an object" right after filling the Address table.
>
>
>
> Public Sub GetProfileTables(ByVal strSQL As String)
>
>
> Dim cnn As New SqlConnection("Server=localhost;
Database=myDatabase;
> UID=user; PWD=password;")
>
> _profileSet = New DataSet("Profile")
> cnn.Open()
>
>
>
> 'Get the profile tables information
>
> ' The SQL statement would be something like SELECT * FROM
vwProfile
> WHERE profile_key = 1110201
>
> ' where the profile key basically is different depending on the
> record being viewed.
>
> Dim daProfile As New SqlDataAdapter(strSQL, cnn)
> daProfile.Fill(_profileSet, "Profile")
> _profileView = _profileSet.Tables("Profile").DefaultView
>
>
>
> 'Get the profile addresses
> strSQL = "select * from address where profile_key = " &
> _profileView(0)("profile_key")
> daProfile.SelectCommand = New SqlCommand(strSQL, cnn)
> daProfile.Fill(_profileSet, "Address")
>
>
>
> 'Define the parent and child columns
> Dim parentCol, childCol As DataColumn
> parentCol = _profileSet.Tables("Profile").Columns("profile_key")
> childCol = _profileSet.Tables("Address").Columns("profile_key") '
> **THIS IS WHERE THE ERROR OCCURS**
>
>
>
> 'Define the relationship of the data
> Dim drProfile As DataRelation
> drProfile = New DataRelation("ProfileAddress", parentCol,
childCol)
> _profileSet.Relations.Add(drProfile)
>
>
>
> cnnITT.Close()
> End Sub
>
>
>
> Any suggestions?
>
>
>
> Thanks
>
> Ryan
>
>



Re: Object reference not set to an instance of an object by Yogs

Yogs
Thu Mar 04 01:09:01 CST 2004

Hi Rajesh,

If I do add in a check to see if it was added, what do I do if it wasn't.
The application expects the "address" table to be there. I was also under
the understanding that the fill command adds the table to the dataset
everytime even if the number of records is 0. Is that incorrect?

Thanks,
Ryan

"Rajesh Patel" <rdp647@hotmail.com> wrote in message
news:uafFLsYAEHA.3712@tk2msftngp13.phx.gbl...
> can you check whether your fill command add "address" datatable into
> _profileset dataset?
>
> Regards,
>
> Rajesh Patel
>
> "Yogs" <ryan@NOSPAMjagdfeld.com> wrote in message
> news:OzV3S4VAEHA.1456@TK2MSFTNGP09.phx.gbl...
> > Hi All,
> >
> >
> >
> > I have an intermittent problem with an SQLDataAdapter.Fill command.
Every
> > now and then the system returns an "Object reference not set to an
> instance
> > of an object" right after filling the Address table.
> >
> >
> >
> > Public Sub GetProfileTables(ByVal strSQL As String)
> >
> >
> > Dim cnn As New SqlConnection("Server=localhost;
> Database=myDatabase;
> > UID=user; PWD=password;")
> >
> > _profileSet = New DataSet("Profile")
> > cnn.Open()
> >
> >
> >
> > 'Get the profile tables information
> >
> > ' The SQL statement would be something like SELECT * FROM
> vwProfile
> > WHERE profile_key = 1110201
> >
> > ' where the profile key basically is different depending on the
> > record being viewed.
> >
> > Dim daProfile As New SqlDataAdapter(strSQL, cnn)
> > daProfile.Fill(_profileSet, "Profile")
> > _profileView = _profileSet.Tables("Profile").DefaultView
> >
> >
> >
> > 'Get the profile addresses
> > strSQL = "select * from address where profile_key = " &
> > _profileView(0)("profile_key")
> > daProfile.SelectCommand = New SqlCommand(strSQL, cnn)
> > daProfile.Fill(_profileSet, "Address")
> >
> >
> >
> > 'Define the parent and child columns
> > Dim parentCol, childCol As DataColumn
> > parentCol = _profileSet.Tables("Profile").Columns("profile_key")
> > childCol = _profileSet.Tables("Address").Columns("profile_key")
'
> > **THIS IS WHERE THE ERROR OCCURS**
> >
> >
> >
> > 'Define the relationship of the data
> > Dim drProfile As DataRelation
> > drProfile = New DataRelation("ProfileAddress", parentCol,
> childCol)
> > _profileSet.Relations.Add(drProfile)
> >
> >
> >
> > cnnITT.Close()
> > End Sub
> >
> >
> >
> > Any suggestions?
> >
> >
> >
> > Thanks
> >
> > Ryan
> >
> >
>
>



Re: Object reference not set to an instance of an object by Rajesh

Rajesh
Thu Mar 04 10:50:19 CST 2004

If it is not there, you can add table manually.

I believe your first table it creates automatically from name given in the
declaration of the dataset. that is profile.
so, add "address" table manually. you can actually see how vs.net add
"profile" table in windows generated code.

Regards,

Rajesh Patel

"Yogs" <ryan@NOSPAMjagdfeld.com> wrote in message
news:eP7n2dbAEHA.1548@TK2MSFTNGP12.phx.gbl...
> Hi Rajesh,
>
> If I do add in a check to see if it was added, what do I do if it wasn't.
> The application expects the "address" table to be there. I was also under
> the understanding that the fill command adds the table to the dataset
> everytime even if the number of records is 0. Is that incorrect?
>
> Thanks,
> Ryan
>
> "Rajesh Patel" <rdp647@hotmail.com> wrote in message
> news:uafFLsYAEHA.3712@tk2msftngp13.phx.gbl...
> > can you check whether your fill command add "address" datatable into
> > _profileset dataset?
> >
> > Regards,
> >
> > Rajesh Patel
> >
> > "Yogs" <ryan@NOSPAMjagdfeld.com> wrote in message
> > news:OzV3S4VAEHA.1456@TK2MSFTNGP09.phx.gbl...
> > > Hi All,
> > >
> > >
> > >
> > > I have an intermittent problem with an SQLDataAdapter.Fill command.
> Every
> > > now and then the system returns an "Object reference not set to an
> > instance
> > > of an object" right after filling the Address table.
> > >
> > >
> > >
> > > Public Sub GetProfileTables(ByVal strSQL As String)
> > >
> > >
> > > Dim cnn As New SqlConnection("Server=localhost;
> > Database=myDatabase;
> > > UID=user; PWD=password;")
> > >
> > > _profileSet = New DataSet("Profile")
> > > cnn.Open()
> > >
> > >
> > >
> > > 'Get the profile tables information
> > >
> > > ' The SQL statement would be something like SELECT * FROM
> > vwProfile
> > > WHERE profile_key = 1110201
> > >
> > > ' where the profile key basically is different depending on
the
> > > record being viewed.
> > >
> > > Dim daProfile As New SqlDataAdapter(strSQL, cnn)
> > > daProfile.Fill(_profileSet, "Profile")
> > > _profileView = _profileSet.Tables("Profile").DefaultView
> > >
> > >
> > >
> > > 'Get the profile addresses
> > > strSQL = "select * from address where profile_key = " &
> > > _profileView(0)("profile_key")
> > > daProfile.SelectCommand = New SqlCommand(strSQL, cnn)
> > > daProfile.Fill(_profileSet, "Address")
> > >
> > >
> > >
> > > 'Define the parent and child columns
> > > Dim parentCol, childCol As DataColumn
> > > parentCol =
_profileSet.Tables("Profile").Columns("profile_key")
> > > childCol =
_profileSet.Tables("Address").Columns("profile_key")
> '
> > > **THIS IS WHERE THE ERROR OCCURS**
> > >
> > >
> > >
> > > 'Define the relationship of the data
> > > Dim drProfile As DataRelation
> > > drProfile = New DataRelation("ProfileAddress", parentCol,
> > childCol)
> > > _profileSet.Relations.Add(drProfile)
> > >
> > >
> > >
> > > cnnITT.Close()
> > > End Sub
> > >
> > >
> > >
> > > Any suggestions?
> > >
> > >
> > >
> > > Thanks
> > >
> > > Ryan
> > >
> > >
> >
> >
>
>