Hi everyone.
I need to know how to return something that holds the data on every row of a data table that is in a data set...
Here's my Stored Procedure:
Note: This will list all the records I need, so that then I'm able to use these same records for another Stored Procedure, thus I need a function that gets this SP as a parameter and then returns the result from it.
Here's my function code:
Note: As you can see on the light-blue text, I have a Dataset with a specific table selected on it and I want get data from that datatable via dataset and return the records, so that I can work with these records later on.
On the marked red text, I'm not sure if I need those lines of code, because from what I understand the adapters are used just to bind data to datagridviews, if that is so I believe I don't need adapters, so I'd like to know if this is true aswell.
Finally, on the yellow text mark, that's where my main question lies, what am I suppose to return, in order to work with the data of each row on the datatable via dataset?
I need to know how to return something that holds the data on every row of a data table that is in a data set...
Here's my Stored Procedure:
Code:
select * from dbo.S4_Artigo
where 0=0 and flag_integrado = 0
order by iduser
Here's my function code:
Code:
Public Function _listarArtigos_viaSP(ByVal NomeSP As String) As DataTable
Dim _instrucaoSQL As New SqlCommand
Dim _SQLlistarArtigosDataReader As SqlDataReader
Dim _minhaLigacaoSQLListarArtigos As New SqlConnection
Dim dsArtigo As New DSPortalS4.S4_ArtigoDataTable
Dim _adaptadorSQLListarArtigos As New SqlDataAdapter
Try
_instrucaoSQL.CommandText = NomeSP
_instrucaoSQL.CommandType = CommandType.StoredProcedure
_instrucaoSQL.Connection = _minhaLigacaoSQLListarArtigos
_adaptadorSQLListarArtigos = New SqlDataAdapter(_instrucaoSQL)
_minhaLigacaoSQLListarArtigos.ConnectionString = _connectionString
_minhaLigacaoSQLListarArtigos.Open()
_adaptadorSQLListarArtigos.SelectCommand = _instrucaoSQL
_adaptadorSQLListarArtigos.Fill(dsArtigo)
return ???
_minhaLigacaoSQLListarArtigos.Close()
Catch _error As Exception
'MessageBox.Show(String.Format("Error: {0}", _error.Message))
_error.ToString()
End Try
Return Nothing
End Sub
On the marked red text, I'm not sure if I need those lines of code, because from what I understand the adapters are used just to bind data to datagridviews, if that is so I believe I don't need adapters, so I'd like to know if this is true aswell.
Finally, on the yellow text mark, that's where my main question lies, what am I suppose to return, in order to work with the data of each row on the datatable via dataset?