create a Dataset Column in int32 or timespan?

  • Thread starter Thread starter Petter L
  • Start date Start date
P

Petter L

I trying to create two columns in a dataset with the type of int32 and
Timespan but i get a message that this is not a valid datatype. In the
example code under the help text on DataType you find following text (cut
out of the helptext)

Dim colInt32 As DataColumn = New DataColumn("Int32Col")
colInt32.DataType = System.Type.GetType("System.Int32")
myTable.Columns.Add(colInt32)

Dim colTimeSpan As DataColumn = New DataColumn("TimeSpanCol")
colTimeSpan.DataType = System.Type.GetType("System.TimeSpan")
myTable.Columns.Add(colTimeSpan)

That take I as it should be possible to do it If not what type can i use for
Time and Integer?

other datatypes works fine within the same code.

Petter L.
 
Hi Petter,

TimeSpan is SqlServer's type. It maps to byte array of size 8.
 
What about the Int32 ?

Petter L.


Miha Markic said:
Hi Petter,

TimeSpan is SqlServer's type. It maps to byte array of size 8.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Petter L said:
I trying to create two columns in a dataset with the type of int32 and
Timespan but i get a message that this is not a valid datatype. In the
example code under the help text on DataType you find following text (cut
out of the helptext)

Dim colInt32 As DataColumn = New DataColumn("Int32Col")
colInt32.DataType = System.Type.GetType("System.Int32")
myTable.Columns.Add(colInt32)

Dim colTimeSpan As DataColumn = New DataColumn("TimeSpanCol")
colTimeSpan.DataType = System.Type.GetType("System.TimeSpan")
myTable.Columns.Add(colTimeSpan)

That take I as it should be possible to do it If not what type can i use for
Time and Integer?

other datatypes works fine within the same code.

Petter L.
 
Petter,

Try this:
colInt32.DataType = GetType(System.Int32)

colTimeSpan .DataType = GetType(System.Byte())


--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com



Petter L said:
What about the Int32 ?

Petter L.


Miha Markic said:
Hi Petter,

TimeSpan is SqlServer's type. It maps to byte array of size 8.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Petter L said:
I trying to create two columns in a dataset with the type of int32 and
Timespan but i get a message that this is not a valid datatype. In the
example code under the help text on DataType you find following text (cut
out of the helptext)

Dim colInt32 As DataColumn = New DataColumn("Int32Col")
colInt32.DataType = System.Type.GetType("System.Int32")
myTable.Columns.Add(colInt32)

Dim colTimeSpan As DataColumn = New DataColumn("TimeSpanCol")
colTimeSpan.DataType = System.Type.GetType("System.TimeSpan")
myTable.Columns.Add(colTimeSpan)

That take I as it should be possible to do it If not what type can i
use
for
Time and Integer?

other datatypes works fine within the same code.

Petter L.
 
I tried the following but the system.int32 did not cleared as valid syntax
ColItem = New DataColumn

With (ColItem)

..ColumnName = Trim(DecVar(0))

..DataType =GetType("System.int32")

end with

The datatype line was previously

..DataType = System.Type.GetType("System.int32")

Petter L.

Miha Markic said:
Petter,

Try this:
colInt32.DataType = GetType(System.Int32)

colTimeSpan .DataType = GetType(System.Byte())


--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com



Petter L said:
What about the Int32 ?

Petter L.


Miha Markic said:
Hi Petter,

TimeSpan is SqlServer's type. It maps to byte array of size 8.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

I trying to create two columns in a dataset with the type of int32 and
Timespan but i get a message that this is not a valid datatype. In the
example code under the help text on DataType you find following text (cut
out of the helptext)

Dim colInt32 As DataColumn = New DataColumn("Int32Col")
colInt32.DataType = System.Type.GetType("System.Int32")
myTable.Columns.Add(colInt32)

Dim colTimeSpan As DataColumn = New DataColumn("TimeSpanCol")
colTimeSpan.DataType = System.Type.GetType("System.TimeSpan")
myTable.Columns.Add(colTimeSpan)

That take I as it should be possible to do it If not what type can i use
for
Time and Integer?

other datatypes works fine within the same code.

Petter L.
 

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