Question

Locked

SQL Server 2000 error and .NET error deciphering

By awildes ·
Hey all,

I have an application that gives the following error upon login:

System.InvalidCastException: Cast from type 'Guid' to type
'String' is not valid.

Without going into detail about the application, can someone give me a generic meaning of this error message? It appears that as long as SQL Server 2000 replication is turned off there is no issue. Any and all help would be greatly appreciated.

Thanks in advance
Always
Alex Wildes
MCITP:SQL SERVER 2005 DBA

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

SQL Server 2000 error and .NET error deciphering

by navyjax2 In reply to SQL Server 2000 error and ...

Probably means you're trying to retrieve a "uniqueidentifier" type, or GUID, from a database using ExecuteScalar() and are casting it to a string type, like this:

sqlCommand sqlCmd = new SqlCommand("SELECT min(Table_Id) FROM Table1", sqlConn);
string myGuid = (string)sqlCmd.ExecuteScalar();

where Table_Id is a column of GUIDs.

Problem is that you can't cast a GUID as a string when retrieving it - has to be of GUID type.

-Tom

Back to Networks Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums