locked
Datatable RRS feed

  • Question

  • User-797751191 posted

    Hi

     I have below function in which i want to retreive DataTable & STored procedure name . IN sp i have stored procedure name. Now i want to fill dataset with sqldataadapter & dt in function costing

    Public Sub Costing( ByRef dt As DataTable, Optional ByRef sp As String = "")

    Thanks

    Wednesday, September 4, 2019 5:24 PM

All replies

  • User475983607 posted

    The function body is empty.  Are you receiving an error?  If so what is the error and can you post the source code?

    Wednesday, September 4, 2019 6:04 PM
  • User409696431 posted

    If you are asking other to write the function for you, that is not the purpose of this forum.  Write the function yourself.  If it gives errors you can't resolve, post your code here and share the error message.

    Wednesday, September 4, 2019 8:14 PM
  • User288213138 posted

    Hi jsshivalik,

    I have below function in which i want to retreive DataTable & STored procedure name . IN sp i have stored procedure name. Now i want to fill dataset with sqldataadapter & dt in function costing

    According to your description, I couldn’t understand your requirement clearly.

    But if you want to fill a DataSet with sqldataadapter & datatable, you can use the following code:

    Dim adapter As SqlDataAdapter = New SqlDataAdapter(cmd)
        Dim dt As DataTable = New DataTable()
        adapter.Fill(dt)
        Dim customers As DataSet = New DataSet()
        adapter.Fill(customers, "Customers")
    

    But since you have stored procedures, why not try use stored procedures to fill a dataset? It's more convenient.

    Dim ds As DataSet = New DataSet()
        Dim da As SqlDataAdapter = New SqlDataAdapter("GetAllUsers", "server=(local);database=DemoDB;Integrated Security=true;")
        da.SelectCommand.CommandType = CommandType.StoredProcedure
        da.Fill(ds)
    

    If I misunderstand your requirement, please post more details information about your requirement.

    Best regards,

    Sam

    Thursday, September 5, 2019 6:29 AM