I use a function to return dataset in which passing a store procedure and MereberID.
It works fine for calling one time but once in for loop, it only works for first loop.
When i=0, it works but when i=1 (second loop), an error occurred: "Object reference not set to an instance of an object"
How to fix it?
dim myds as new dataset
For i As Integer = 0 To listboxmember.Items.Count - 1
myds = GetSPDataSet("mystoreprocedure", listboxmember.items(i))
'some codes here'
next
Public Function GetSPDataSet(ByVal SPName As String, ByVal _membid As String) As DataSet
Dim MyConnection As SqlConnection
Dim MyCommand As SqlCommand
Dim MyDataSet As New DataSet
Dim MySQLDataAdapter As SqlDataAdapter
MyConnection = MYSQLCONNECTION
MyCommand = New SqlCommand(SPName, MyConnection)
MyCom ...
Go to the complete details ...