PC Review


Reply
Thread Tools Rate Thread

How to retrieve TimeSpan from typed DataSet?

 
 
deko
Guest
Posts: n/a
 
      7th Mar 2006
I keep getting an InvalidCast exception when trying to do this:

DataRow row = dtP.Rows.Find(projectID);
bakInterval = new TimeSpan();
bakInterval = (TimeSpan)row[colBI]; //colBI is a string const

Error Message: "Specified cast is not valid".

As far as I know, the rowBI column is in fact a TimeSpan. Below is how the
dtP table is created. The last line shows colBI created as a TimeSpan type.

DataTable tblProject = database.Tables.Add("TableProject");
DataColumn project_ID = tblProject.Columns.Add("Project_ID",
typeof(Int32));
project_ID.AllowDBNull = false;
project_ID.Unique = true;
project_ID.AutoIncrement = true;
project_ID.AutoIncrementSeed = 1;
project_ID.AutoIncrementStep = 1;
tblProject.PrimaryKey = new DataColumn[] { tblProject.Columns[0] };
tblProject.Columns.Add("ProjectName", typeof(string));
tblProject.Columns.Add("BackupInterval", typeof(TimeSpan));

I can cast ProjectName to a string, and Project_ID to an int, but I can't
cast BackupInterval to a TimeSpan.

What am I doing wrong?

Thanks in advance.


 
Reply With Quote
 
 
 
 
deko
Guest
Posts: n/a
 
      8th Mar 2006
I figured it out... had to do with out parameters
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Strongly Typed DataSet Vs Un-Typed Dataset =?Utf-8?B?Sm9iIExvdA==?= Microsoft Dot NET 1 5th May 2005 08:43 AM
Typed DataSet Vs Un-Typed DataSet =?Utf-8?B?Sm9iIExvdA==?= Microsoft Dot NET 1 22nd Feb 2005 11:18 AM
How can I add a row from a typed datatable to another instance of that typed datatable? Ersin Gençtürk Microsoft ASP .NET 1 6th Oct 2004 02:11 PM
typed vs strong typed dataset Brad Allison Microsoft ADO .NET 3 21st Jul 2004 04:34 PM
Cast weakly typed DataSet to a strongly typed dataset??? Microsoft Dot NET 0 18th Sep 2003 10:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:47 AM.