Reputation: 3185
I am using WinForms and trying to retrieve all the data from the database once on form Load so I won't have to go back and forth to the database a lot.
I created a class and wrote a function that returns a dataset but I'm not being able to refer to it from my forms.
This is the code:
Private Function FillKeywords() As DataSet
Dim ds1 As DataSet : Dim cmd as SqlCommand
Dim da As SqlDataAdapter
Try
cmd = New SqlCommand("Dbo.selectkeywords", cn)
cmd.CommandType = CommandType.StoredProcedure
da = New SqlDataAdapter(cmd)
ds1 = New DataSet
da.Fill(ds1, "Keywords")
Return ds1
Catch ex As SqlClient.SqlException
WriteExToFile(ex.ToString)
Catch ex As Exception
WriteExToFile(ex.ToString)
End Try
End Function
Upvotes: 0
Views: 2616
Reputation: 77364
I'll take a wild guess and say you will need to lose the Private
keyword if you want your function to be accessible from another class or module.
Upvotes: 3