Y
Yogs
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
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