DataTable and ParameterDirection

  • Thread starter Thread starter kurt sune
  • Start date Start date
K

kurt sune

I am trying to use a DataTable as a transporting container between
components for data to be inserted into sql server via a stored procedure.

The idea is to extract data, rowcolumn by rowcolumn, from the datatable,
remake them to parameters, append the parameters to a commandobject and pass
the lot to the procedure.

I can put in a column names and column data.into the datatable.
All is well so far.
But I need a way to transport the direction
(ParameterDirection.Input, InputOutput, Output)
in the datatable in order to get the parameterobject right..

Any tips/ideas?

/k
 
An easier way might just be to create an Array orArrayList of Paramater
objects. Using the data you have, you can populate the params
iteratively,then walk through them iteratively to build your command.
 
I'm not sure I understand but let me try. Are you saying that you just want
a way to pass a little more information when you pass your table to the
other components? What I would do is to create a new DataColumn class and
add a new property to it called "Direction". When creating the table add
your new DataColumn class to the table.


Sub Main
Dim T As New DataTable
Dim ExDC_In As New ExDataColumn
ExDC_In.Direction = "Test"
T.Columns.Add(ExDC_In)
ExDC_In = New ExDataColumn
ExDC_In.Direction = "Test 2"
T.Columns.Add(ExDC_In)
Dim ExDC As ExDataColumn
ExDC = DirectCast(T.Columns(1), ExDataColumn)
Debug.WriteLine(ExDC.Direction)
End Sub

Public Class ExDataColumn
Inherits DataColumn
Dim mDirection As String
Public Property Direction() As String
Get
Return mDirection
End Get
Set(ByVal Value As String)
mDirection = Value
End Set
End Property
End Class

Hope this helps.
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top