I am trying to create a function that passes a Dataset. I know the code
works because if I cut and paste it on my file in code behind it works
fine.

The actual task is to create the Dataset from a SQLDataAdapter within a
function. Then I want to call the function to fill a dropdown list on
my .aspx page.

Here is the current code that I am using in the function. I am unaware
of what I should be using on the .aspx page.

Any and all help is appreciated.

Public Function ShowRootFolders(ByVal ClientID As String) As DataSet

Dim Connect As String
Dim CompanyDataSet As DataSet
Dim GetCompanys As SqlClient.SqlDataAdapter

Connect =
ConfigurationSettings.AppSettings("THE_Connection")

Dim Connection As New SqlClient.SqlConnection(Connect)

Connection.Open()

GetCompanys = New SqlClient.SqlDataAdapter("Select * from
rootfolders where clientID = '" + ClientID + "'", Connection)
CompanyDataSet = New DataSet

GetCompanys.Fill(CompanyDataSet, "AllTables")

DMConnection.Close()

Return ShowRootFolders

Re: FUNCTION as DATASET by David

David
Mon Aug 29 14:43:37 CDT 2005


<davis@ds3cs.com> wrote in message
news:1125344129.884135.302040@z14g2000cwz.googlegroups.com...
>I am trying to create a function that passes a Dataset. I know the code
> works because if I cut and paste it on my file in code behind it works
> fine.
>
> The actual task is to create the Dataset from a SQLDataAdapter within a
> function. Then I want to call the function to fill a dropdown list on
> my .aspx page.
>
> Here is the current code that I am using in the function. I am unaware
> of what I should be using on the .aspx page.
>
> Any and all help is appreciated.
>
> Public Function ShowRootFolders(ByVal ClientID As String) As DataSet
>
> Dim Connect As String
> Dim CompanyDataSet As DataSet
> Dim GetCompanys As SqlClient.SqlDataAdapter
>
> Connect =
> ConfigurationSettings.AppSettings("THE_Connection")
>
> Dim Connection As New SqlClient.SqlConnection(Connect)
>
> Connection.Open()
>
> GetCompanys = New SqlClient.SqlDataAdapter("Select * from
> rootfolders where clientID = '" + ClientID + "'", Connection)
> CompanyDataSet = New DataSet
>
> GetCompanys.Fill(CompanyDataSet, "AllTables")
>
> DMConnection.Close()
>
> Return ShowRootFolders
>

You should be returning CompanyDataSet, not ShowRootFolders, which is
Nothing.

David



Re: FUNCTION as DATASET by Scott

Scott
Mon Aug 29 14:54:56 CDT 2005

You are havning your function return itself. You need to have it return
CompanyDataSet.


<davis@ds3cs.com> wrote in message
news:1125344129.884135.302040@z14g2000cwz.googlegroups.com...
>I am trying to create a function that passes a Dataset. I know the code
> works because if I cut and paste it on my file in code behind it works
> fine.
>
> The actual task is to create the Dataset from a SQLDataAdapter within a
> function. Then I want to call the function to fill a dropdown list on
> my .aspx page.
>
> Here is the current code that I am using in the function. I am unaware
> of what I should be using on the .aspx page.
>
> Any and all help is appreciated.
>
> Public Function ShowRootFolders(ByVal ClientID As String) As DataSet
>
> Dim Connect As String
> Dim CompanyDataSet As DataSet
> Dim GetCompanys As SqlClient.SqlDataAdapter
>
> Connect =
> ConfigurationSettings.AppSettings("THE_Connection")
>
> Dim Connection As New SqlClient.SqlConnection(Connect)
>
> Connection.Open()
>
> GetCompanys = New SqlClient.SqlDataAdapter("Select * from
> rootfolders where clientID = '" + ClientID + "'", Connection)
> CompanyDataSet = New DataSet
>
> GetCompanys.Fill(CompanyDataSet, "AllTables")
>
> DMConnection.Close()
>
> Return ShowRootFolders
>