Re: Retrieving a Guid from a DataTable
- From: "AlveenX" <JWandera@xxxxxxxxx>
- Date: 5 Jul 2006 07:03:14 -0700
Hans, the column has a Uniqueidentifier data type. However, my table
does not accept nulls - so there are no null values.
Tom, the GUID is stored as a Uniqueidentifier in the database. But in
the application row["ID"].GetType() returns System.Guid
Ignacio, as specified above, the table has a column of uniqueidentifier
data type. I have a method with the following:
ArrayList ReadingRange = new ArrayList();
try
{
DataTable tblReadings = Access.GetAllReadings();// populates the
tblReadings dataTable
if (tblReadings == null)
{
MessageBox.Show("No data found!!!");
}
else
{
foreach(DataRow row in tblReadings.Rows)
{
//Reading class with parameter of type System.Guid
Reading reading = new Reading(
(Guid)row["ID"],
);
ReadingRange.Add(Reading);
}
return ReadingRange;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
return ReadingRange;
/// ******* I am still getting the same error message!!!
AlveenX wrote:
Hi,
I am trying to pick a Guid from a data row using the following code:
foreach(DataRow row in MyDataTable.Rows)
{
(Guid)row["ID"]
}
However, this is the error I'm getting: System.InvalidCastException:
Specified Cast is not Valid. Do you know how I can cast the row entry
so that I end up retrieving the Guid?
Thanks,
Alveen
.
- Follow-Ups:
- Re: Retrieving a Guid from a DataTable
- From: Sericinus hunter
- Re: Retrieving a Guid from a DataTable
- References:
- Retrieving a Guid from a DataTable
- From: AlveenX
- Retrieving a Guid from a DataTable
- Prev by Date: Re: C# run Windows Service project as regular Windows application
- Next by Date: Re: XML Serialization
- Previous by thread: Re: Retrieving a Guid from a DataTable
- Next by thread: Re: Retrieving a Guid from a DataTable
- Index(es):
Relevant Pages
|