.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

cannot be applied to operands of type 'string' and 'System.Guid'

Posted By:      Posted Date: September 18, 2010    Points: 0   Category :ASP.Net
MembershipUser myObject = Membership.GetUser(); string UserID = myObject.ProviderUserKey.ToString(); BurnbetDataContext db = new BurnbetDataContext(); var creditcard = from c in db.tbl_Payments where UserID == c.UserId select c; Column UserId = uniqueidentifier Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS0019: Operator '==' cannot be applied to operands of type 'string' and 'System.Guid'Source Error: Line 93: Line 94: var creditcard = from c in db.tbl_Payments Line 95: where UserID == c.UserId Line 96: select c; Line 97: Please help!

View Complete Post

More Related Resource Links

Unable to cast object of type 'System.Guid' to type 'System.String'.

protected void Button1_Click(object sender, EventArgs e) { using (BurnbetDataContext dc = new BurnbetDataContext()) { var q = (from c in dc.GetTable<tbl_Payment>() where c.ID == 5 select c).Single<tbl_Payment>(); dc.GetTable<tbl_Payment>().DeleteOnSubmit(q); dc.SubmitChanges(); } } }System.InvalidCastException was unhandled by user code  Message=Unable to cast object of type 'System.Guid' to type 'System.String'.  Source=System.Data.Linq  StackTrace:       at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)       at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)       at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)       at System.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)&nb

Operator '>=' cannot be applied to operands of type 'string' and 'string'


I want to compare two lebel text , but i am getting this error..

Compiler Error Message: CS0019: Operator '>=' cannot be applied to operands of type 'string' and 'string'

Source Error:

Line 39:         Label2.Text = DateTime.Now.AddDays(7).ToString("MM/dd/yyyy");
Line 40: Label3.Text = DateTime.Now.ToString("MM/dd/yyyy");
Line 41: if (Label2.Text>=Label2.Text)
Line 42: {

plz reply me ...how can i compare greater than and greater than equal to values of labels...


//Operator '+' cannot be applied to operands of type 'L' and 'L'

  public L Mymethod<L>(L mydate, L myname) {   //it is getting following errro   //Operator '+' cannot be applied to operands of type 'L' and 'L'   return (myname+myname); }   Can any one give me help how to solve following error

Unable to cast object of type 'System.DBNull' to type 'System.String'.


 I saw lots of post about this issue. but haven't got good solution for that yet. Basically, what I did is that: I have a table in SQL database and some of data fields allow null. I built Objectdatasource through dataset. When I built update page using dataset. It generate the following error before showing the update page correctly. It seems I have issue to retrieve the null value from the database through using objectdatasource through dataset. Any suggestions?




Error attached below:

Unable to cast object of type 'System.DBNull' to type 'System.String'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.String'.

Source Error:

Line 1178:            get {
Line 1179:                try {
Line 1180:                    return ((string)(this[this.tablemember.CurrentCityStateColumn]));
Line 1181:                

Object of type 'System.Int32' cannot be converted to type 'System.String


When i'm trying to update a table using dynamic data, i'm getting the following error. I was trying to google the solution for the whole day, but it didnt work. I tried to declare the type of parameters like this

<asp:LinqDataSource ID="DetailsDataSource" runat="server" EnableUpdate="true"
                onupdating="DetailsDataSource_Updating" > <UpdateParameters><asp:Parameter Name="PK_ID" Type="Int32" /><asp:Parameter Name="id" Type="Int32" />
                <asp:Parameter Name="c_titulu" Type="Int32" />
                <asp:Parameter Name="perio" Type="Int32" />

Unable to convert type System.String to System.Web.DynamicData.MetaTable



I am encountering the problem  "Unable to convert type System.String to System.Web.DynamicData.MetaTable" when I hit one of the tables for List.aspx.  It is using the DynamicData/PageTemplates/List.aspx and this error is not happening in other tables.

It is happening on the line

GridView1.SetMetaTable(table, table.GetColumnValuesFromRoute(Context));

If you have any leads, please let me know.



System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPerm


Good Day all,

Having an issue with an outside user accessing my IIS7 box. I do not have this problem when running the website from my host machine. I found this post: Http://forums.asp.net/t/1371394.aspx. I assure you that this is not a solution because I am not storing any of my files on a network share. 

What do you think my approach should be. 

I already have read rights to IIS user to my BIN folder. 

Thanks for the help. 

The type 'System.Data.Linq.DataContext' is defined in an assembly that is not referenced. You must



This is frustrating, and I don't know how to solve it.

I have a strange problem. I am adding a LinqDatasource object, and set the context:

        protected void LinqDataSource_ContextCreating(object sender, LinqDataSourceContextEventArgs e)
            e.ObjectInstance = new KaruselaDataContext(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);

Then I get this error:
The type 'System.Data.Linq.DataContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Linq, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.


On web.config I already have this:
<add assembly="System.Data.Linq, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

NOTE: The datacontext is in a different project (DLL proect) where I added a refernce to System.Data.Linq.

is there another way adding a refernce to a web project? or only though teh web.config?


Maximum memory for string ? . System.MemoryOutOfException Occurs when reading the Content of the fil



I have a C++ code which reads a file [vtk file - its similar to text file only]. and try to store it in string.

here's the code:

String^ ParallelProjectionRenderer::GetVolumeDataAsString(String^ FileName)

    vtkSmartPointer<vtkDataSetWriter> sWriter = vtkSmartPointer<vtkDataSetWriter>::New();

    String^ FileName = "D:\\Users\\...";

    char * sptName = static_cast<char *>(Marshal::StringToHGlobalAnsi(FileName).ToPointer());







    String^ result= File::ReadAllText(FileName);   [it breaks here with system.memoryoutofexception when the file size is huge]

    return result;


this code executes fine when the file size is less than 8mb.

I wanted to know whats the maximum memory allocated to the string.

As a workaround i skipped reading out in C++ code. and i tried to read the file contents in asp.net C# code and stor

Netting C++: Mapping Native C++ to the Common Type System


This month Stanley Lippman begins translating the Text Query Language Query class hierarchy from C++ to the .NET Common Type System.

Stanley B. Lippman

MSDN Magazine February 2007

Netting C++: The Design Space of the Common Type System


Stanley Lippman moves Text Query Language to the Microsoft .NET Framework using the C++/CLI language extensions in Visual C++ 2005.

Stanley B. Lippman

MSDN Magazine December 2006

Types in Yukon: Managed UDTs Let You Extend the SQL Server Type System


The next version of SQL Server, code-named "Yukon," will offer enhanced support for user-defined types (UDTs). Because UDTs can be managed by the CLR, you can represent a wide variety of data structures to create types not possible with previous versions of SQL Server. With UDTs you can more precisely control the kind of data your type accepts, resulting in better data management. This article explores UDTs in "Yukon" and covers their design and implementation.

Peter W. DeBetta

MSDN Magazine February 2004

Unable to cast object of type 'System.Web.Mvc.ValueProviderResult' to type 'System.IConvertible'


 Why am I getting this error on line:

               sp.Price = Convert.ToDecimal(collection.GetValue("Price"));

sp is :
  SPecials_Templates sp = new SPecials_Templates();

SPecials_Templates Defined:

    public partial class SPecials_Templates
        public class SPecials_TemplatesMetaData

            public object Key { get; set; }
            public object Template_Name { get; set; }
            public object Headline { get; set; }

Failed to convert parameter value from a String to a Guid.


I am trying to get the UserRole from the logged in user and send it to the database table my code is:

SqlParameter FamilyFriendsOther = new SqlParameter("@Role", SqlDbType.UniqueIdentifier);
        string [] roles = System.Web.Security.Roles.GetRolesForUser();
        if (roles.Length > 0)
            FamilyFriendsOther.Value = roles[0];

Conversion from string to type 'Date' is not valid



Im receiving a strange error Error Message: Conversion from string "15/08/2010 22:21:35" to type 'Date' is not valid.

I know this is generally down to cultural date formats etc, however the reason this is strange is it just randomly occured twice in the last week, the website has been running since october and nothing has changed,

The error constantly occured until the IIS was reset and recompilled the site, its been running fine since, however im just trying to figure out what could cause such an error to occur.

I've narrowed it down to a line of code which is:

bktime = DReader.Item("Bktime").ToString

bktime = Year(CDate(bktime)) & "-" & fmt(Month(CDate(bktime)), 2) & "-" & fmt(Day(CDate(bktime)), 2)

Has anyone else encountered this randomly occuring and is there anything i can put in place to prevent this in future?



An unhandled exception of type 'System.Net.Sockets.SocketException' occurred in system.dll

Additional information: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respondThis error occurs when i was executing a vc++.net program implementing ICMP....Error occurs when executing this statement... iRet=st->ReceiveFrom(RecvByte,RecvByte->Length,SocketFlags::None,&senderRemote);How to solve this problem????

System.Security.SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlCli

I have created a windows library control that accesses a local sql database I tried the following strings for connecting Dim connectionString As String = "Data Source=localhost\SQLEXPRESS;Initial Catalog=TimeSheet;Trusted_Connection = true" Dim connectionString As String = "Data Source=localhost\SQLEXPRESS;Initial Catalog=TimeSheet;Integrated Security=SSPI"   I am not running the webpage in a virtual directory but in C:\Inetpub\wwwroot\usercontrol and I have a simple index.html that tries to read from an sql db but throws the error System.Security.SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.   at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)   at System.Security.PermissionSet.Demand()   at System.Data.Common.DbConnectionOptions.DemandPermission()   at System.Data.SqlClient.SqlConnection.PermissionDemand()   at System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection)   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, etc etc  The action that failed was:DemandThe type of the first permission that failed was:System.Data.SqlClient.SqlClientPermissionThe Zone of the assembly that fa
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend