ADO.NET :: Unable To Cast Object Of Type System.Guid To Type System.String?
Sep 17, 2010
[Code]....
System.InvalidCastException was unhandled by user code
Message=Unable to cast object of type 'System.Guid' to type 'System.String'.
Source=System.Data.Linq
System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execut
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?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
I am trying to write a table output from SQL database to a gridview/ Data List through an Object Data Source. I am a new starter and your help will be useful.
public List<Staff> GetStaff() cmd.CommandType = SqlConnection con = new SqlConnection(connectionstring);SqlCommand cmd = new [code]...
Above is my code. The error I'm get is, Unable to cast object of type 'System.DateTime' to type 'System.String'.
The column "To" and column "Subject" are strings and column "Receive" is DateTime. I can't made any changes in the database, so I need to write some code to handle casting a string to datetime or if statement as a work around.
This error is occuring randomly, and I can't seem to pinpoint what is causing it. For the most part, the code works fine. I'm confused why it works sometimes, but then suddently craps out on me, lol.It happens in the code when I call upon the asp.net membership provider. It only seems to happen when i use Membership.GetUser() to grab the logged in user's information.
I want to do paging the API Membership without using the datacontrols, but I get this error "Unable to cast object of type '<TakeIterator>d__3a`1[System.Char]' to type 'System.Collections.IList'." when I do this,
Protected Sub FormView1_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewCommandEventArgs) Handles FormView1.ItemCreated Causes Unable to cast object of type 'System.EventArgs' to type 'System.Web.UI.WebControls.FormViewCommandEventArgs'.
The program (asp.net/vb) works fine with FormView1_ItemCommand and FormView1_ItemInserted events but strangely objects to FormView1_ItemCreated. Is it only a VC# event?
what is wrong with this syntax datatable temp = (DataTable)du.Rows[0]["NAME"] I get the error message Unable to cast object of type 'System.String' to type 'System.Data.DataTable'.
I have a web site that is using windows authentication. 'Enable anonymous access' is unchecked. It works when I call it through Visual Studio but when I put the site on the server I get the following error:
Unable to cast object of type 'System.Security.Principal.GenericPrincipal' to type 'System.Web.Security.RolePrincipal'.
I've got a subweb as application. It's called ADMIN. It works fine when running locally but when deploying in the development web server, i got the error: Unable to cast object of type 'System.Web.HttpApplication' to type 'Microsoft.Practices.CompositeWeb.WebClientApplication'
I've got a App_global.asax.dll and App_global.asax.complied on the subweb folder Admin.
The ChecBox will be selected according to the user need: 1, 2, 3 or plus... When the page is fired, I wanted to get in the code behind the box which are checked so I can build a query consequently. So in the code behin, i wrote this:
Dim MyCheckBox As CheckBox Even if I try Dim MyCheckBox As New CheckBox I was getting the same error below. For Each MyCheckBox In Form.Controls For j As Integer = 1 To 12 If TypeOf MyCheckBox Is CheckBox Then MyCheckBox.ID = MonthName(j) If CType(MyCheckBox, CheckBox).Checked = True Then TargetedFieldName = MyCheckBox.ID 'Build a query against tables MyCheckBoxCollection += TargetedFieldName & ", " End If End If Next Next
I'm getting right after For Each statement this error: Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'System.Web.UI.WebControls.CheckBox'.
I need some help on the row updating for a gridview that i bind manually to a list, not using objectdatasource or sqldatasourcehere is my rowupdating. What i want to do for now is just get the values from the textboxes and I will store them to sting variables then I will call my update function and pass those as parameters. How do I get the data from the textboxes that the user just edited. I have the following but I am getting an error: "unable to cast object of type System.UI.LiteralControl to type System.UI.TextBox
I have implemented rights based security as I describe here: http://forums.asp.net/p/1380280/2916291.aspxThis has been working well for awhile now, but I am moving the site to IIS 7 and encountering problems. I am able to reach the login screen for my app - but upon login get this error: "Unable to cast object of type 'System.Web.Security.RolePrincipal' to type 'RightsLib.RightPrincipal'."As described in the linked post, I have a "RightsLib.dll" that contains the relevant classes like "RightsHttpModule.cs", "RightPrincipal.cs" etc...My app no longer seems to be able to work with RightsLib.dll. RightsLib.dll resides in the bin directory of my app, and I have a reference to it in my project.me what I'm doing wrong, or what has changed to affect this in IIS 7?The only relevant entry in Web.config I'm aware of.
I am trying to pass a collection of Dropdown controls as a parameter to a method which takes a collection of type Control as input. While executing I get the following error:
"Unable to cast object of type 'd__a31[System.Web.UI.WebControls.DropDownList]' to type 'System.Collections.Generic.IEnumerable1[System.Web.UI.Control]'."
I wanted to delete the record from data but I receive this error "Unable to cast object of type 'System.Data.Linq.DataQuery`1[training_eval.Course]' to type 'training_eval.Course'.
Dim eval_sure = From ev In db.Evaluates Where ev.course_id = indexcourse Select ev.course_id Dim del_course = From c In db.Courses Where c.Course_id = indexcourse db.Courses.DeleteOnSubmit(del_course) db.SubmitChanges()
Trying to explain this clearly. I have a dropdown listbox where user can select multiple names. These names are then selected/inserted into db table in a loop. Table is displayed in an editable gridview. I have a main sqldatasource1 on my aspx page with select/insert/update permissions, but because select command doesnt work with parameters of multiple values (or does it?), i resorted to using an alternative sql datasource in the codebehind in order to run the select query on the multiple values chosen from the dropdownlist to see if they were in my table.I now get this error when I go to select multiple names from the dropdown list
Unable to cast object of type 'System.Data.Common.DataRecordInternal' to type 'System.Data.DataRowView'.
I am attempting to use SqlBulkCopy to import data from an XML document. I receive the following error when executing WriteToServer: Invalid cast from 'System.String' to 'System.Guid'
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:
[Code]....
Line 93: Line 94: var creditcard = from c in db.tbl_Payments Line 95: where UserID == c.UserId Line 96: select c; Line 97:
I am trying to upload a picture into database using FormView insertItemTemplate. FormView is bounded by objectdatasource.To upload, I placed FileUpload control inside insertItemTemplate.In table the dataType is image.Error:Object of type 'System.Boolean' cannot be converted to type 'System.Byte[]'.