473,241 Members | 1,690 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

datacolumn

im Trying to set a Datacolumn type for a new table

boolean is not working, What is the correct waty

//column.DataType = System.Type.GetType"System.Data.SqlTypes.SqlBoolea n");

column.DataType = System.Type.GetType"System.Boolean"); //"System.Boolean");

tia

Dave


Sep 16 '07 #1
3 6172
the above is corrected....
but im haveing a problem creating a datacolumn for sqlmoney
examples plz

DaveP

"DaveP" <dv*****@sbcglobal.netwrote in message
news:aP****************@newssvr14.news.prodigy.net ...
im Trying to set a Datacolumn type for a new table

boolean is not working, What is the correct waty

//column.DataType = System.Type.GetType"System.Data.SqlTypes.SqlBoolea n");

column.DataType = System.Type.GetType"System.Boolean");
//"System.Boolean");

tia

Dave


Sep 16 '07 #2
hello,
check this sample

public DataTable MakeDataTable(){

DataTable myTable;
DataRow myNewRow;
// Create a new DataTable.
myTable = new DataTable("My Table");

// Create DataColumn objects of data types.
DataColumn colString = new DataColumn("StringCol");
colString.DataType = System.Type.GetType("System.String");
myTable.Columns.Add(colString);

DataColumn colInt32 = new DataColumn("Int32Col");
colInt32.DataType = System.Type.GetType("System.Int32");
myTable.Columns.Add(colInt32);

DataColumn colBoolean = new DataColumn("BooleanCol");
colBoolean.DataType = System.Type.GetType("System.Boolean");
myTable.Columns.Add(colBoolean);

DataColumn colTimeSpan = new DataColumn("TimeSpanCol");
colTimeSpan.DataType = System.Type.GetType("System.TimeSpan");
myTable.Columns.Add(colTimeSpan);

DataColumn colDateTime = new DataColumn("DateTimeCol");
colDateTime.DataType = System.Type.GetType("System.DateTime");
myTable.Columns.Add(colDateTime);

DataColumn colDecimal = new DataColumn("DecimalCol");
colDecimal.DataType = System.Type.GetType("System.Decimal");
myTable.Columns.Add(colDecimal);

// Populate one row with values.
myNewRow = myTable.NewRow();

myNewRow["StringCol"] = "Item Name";
myNewRow["Int32Col"] = 2147483647;
myNewRow["BooleanCol"] = true;
myNewRow["TimeSpanCol"] = new TimeSpan(10,22,10,15,100);
myNewRow["DateTimeCol"] = System.DateTime.Today;
myNewRow["DecimalCol"] = 64.0021;
myTable.Rows.Add(myNewRow);
return myTable;
}

Cheers !

Husam Al-A'araj
www.aaraj.net
"DaveP" wrote:
im Trying to set a Datacolumn type for a new table

boolean is not working, What is the correct waty

//column.DataType = System.Type.GetType"System.Data.SqlTypes.SqlBoolea n");

column.DataType = System.Type.GetType"System.Boolean"); //"System.Boolean");

tia

Dave


Sep 16 '07 #3
thanks alot
Davep

"Husam Al-A''araj" <Hu**********@discussions.microsoft.comwrote in message
news:BE**********************************@microsof t.com...
hello,
check this sample

public DataTable MakeDataTable(){

DataTable myTable;
DataRow myNewRow;
// Create a new DataTable.
myTable = new DataTable("My Table");

// Create DataColumn objects of data types.
DataColumn colString = new DataColumn("StringCol");
colString.DataType = System.Type.GetType("System.String");
myTable.Columns.Add(colString);

DataColumn colInt32 = new DataColumn("Int32Col");
colInt32.DataType = System.Type.GetType("System.Int32");
myTable.Columns.Add(colInt32);

DataColumn colBoolean = new DataColumn("BooleanCol");
colBoolean.DataType = System.Type.GetType("System.Boolean");
myTable.Columns.Add(colBoolean);

DataColumn colTimeSpan = new DataColumn("TimeSpanCol");
colTimeSpan.DataType = System.Type.GetType("System.TimeSpan");
myTable.Columns.Add(colTimeSpan);

DataColumn colDateTime = new DataColumn("DateTimeCol");
colDateTime.DataType = System.Type.GetType("System.DateTime");
myTable.Columns.Add(colDateTime);

DataColumn colDecimal = new DataColumn("DecimalCol");
colDecimal.DataType = System.Type.GetType("System.Decimal");
myTable.Columns.Add(colDecimal);

// Populate one row with values.
myNewRow = myTable.NewRow();

myNewRow["StringCol"] = "Item Name";
myNewRow["Int32Col"] = 2147483647;
myNewRow["BooleanCol"] = true;
myNewRow["TimeSpanCol"] = new TimeSpan(10,22,10,15,100);
myNewRow["DateTimeCol"] = System.DateTime.Today;
myNewRow["DecimalCol"] = 64.0021;
myTable.Rows.Add(myNewRow);
return myTable;
}

Cheers !

Husam Al-A'araj
www.aaraj.net
"DaveP" wrote:
>im Trying to set a Datacolumn type for a new table

boolean is not working, What is the correct waty

//column.DataType =
System.Type.GetType"System.Data.SqlTypes.SqlBoole an");

column.DataType = System.Type.GetType"System.Boolean");
//"System.Boolean");

tia

Dave



Sep 16 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: J | last post by:
Is there anyway to format a calculated datacolumn? I would like the following column to display as money (formatted as $#,##0.00). Or how about simply displaying the column formatted as a number...
1
by: Chris | last post by:
I'm having trouble Serializing a System.Data.DataColumn object. When I try to serialize it, I get the following: System.NotSupportedException: Cannot serialize member...
5
by: JC Voon | last post by:
Hi: How to reset the autoincrement value generated by DataTable ? I've master and detail table, the detail table has a autoincrement column, each time i add a new master record, i need to...
4
by: bordsby | last post by:
Situation: I am using an OleDbDataAdapter to fill a DataSet's DataTable with data from an Access database. The DataSet's DataTable is bound to a DataGrid. After the OleDbDataAdapter.Fill method...
1
by: Jay Balapa | last post by:
Hello, Iam trying to do the following- if(myColumn.DataType==typeof(bool)) { } this does not work either Type.GetType("System.Boolean") instead of typeof(bool).
1
by: mfunkmann | last post by:
Hi, I recently got an error and I don't know how to fix it: Error 1 'System.Data.DataColumn' does not contain a definition for 'Windows' C:\c#\CsharpPRO\Form1.Designer.cs 304 77 CsharpPRO I...
11
by: Matt F | last post by:
I'm trying to do something that seems like it should be pretty simple, but haven't found a solution. I am trying to add a datacolumn to a datatable that adds or subtracts a number of days based on...
0
by: SWIL | last post by:
Hi, I made my own datacolumn Class which inherits from Data.DataColumn. To this class I have added 2 properties. To add datacolumn created through my new class I have to call.. ...
0
by: SMH | last post by:
Hi All, I am currently learning .Net 2, studying for 70-528. I've hit a bit of a brick wall with DataColumn.Expression. As I understand it, this can be used to (For example) concatenate two...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.