Hello All,
Please help. I get the following error from my webpage:
System.InvalidC astException: Specified cast is not valid.
at Time.MaintAtRis kProjects.Updat eProject(String Project, String
AtRiskCode, String Comment)
Code for UpdateProject(S tring Project, String AtRiskCode, String Comment)
is:
Private Sub UpdateProject(B yVal Project As String, ByVal AtRiskCode As
String, ByVal Comment As String)
Try
Dim strProject As String = Trim(Project)
Dim strAtRiskCode As String = Trim(AtRiskCode )
Dim strComment As String = Trim(Comment)
Dim r As AtRiskProjectsD S.AtRiskProject sRow
Dim rows() As AtRiskProjectsD S.AtRiskProject sRow =
AtRiskProjDS.At RiskProjects.Se lect(AtRiskProj DS.AtRiskProjec ts.ProjectColum n.ColumnName
& "= '" & strProject & "' AND " &
AtRiskProjDS.At RiskProjects.At RiskCodeColumn. ColumnName & "= '" &
strAtRiskCode & "' ")
If rows.Length <> 0 Then
r = rows(0)
If r.Comment <> strComment Then
r.Comment = strComment
End If
End If
Catch ex As Exception
Trace.Write(ex. ToString)
End Try
End Sub
UpdateProject(B yVal Project As String, ByVal AtRiskCode As String, ByVal
Comment As String) is being called from an update button I have in the page.
The code for Update click is as follows:
Private Sub btnUpdate_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnUpdate.Click
Try
Dim strProject As String = Trim(lblProject .Text)
AtRiskProjDS.Cl ear()
AtRiskProjDS = LoadAtRiskProjD S(strProject)
For Each item As DataGridItem In dgAtRiskInfo.It ems
If item.ItemType = ListItemType.It em Or item.ItemType =
ListItemType.Al ternatingItem Then
Dim RiskCodeOld As CheckBox = CType(item.Find Control("chkCod eOld"),
CheckBox)
Dim RiskCodeNew As CheckBox = CType(item.Find Control("chkCod eNew"),
CheckBox)
Dim AtRiskCode As TextBox = CType(item.Find Control("txtAtR iskCode"),
TextBox)
Dim Description As Label = CType(item.Find Control("lblDes cription"), Label)
Dim Comment As TextBox = CType(item.Find Control("txtCom ment"), TextBox)
Dim strAtRiskCode As String = Trim(AtRiskCode .Text)
Dim strDescription As String = Trim(Descriptio n.Text)
Dim strComment As String = Trim(Comment.Te xt)
If RiskCodeOld.Che cked = False And RiskCodeNew.Che cked = True Then
InsertProject(R iskCodeNew.Chec ked, strProject, strAtRiskCode,
strDescription, strComment)
RiskCodeOld.Che cked = RiskCodeNew.Che cked
ElseIf RiskCodeOld.Che cked = True And RiskCodeNew.Che cked = False Then
DeleteProject(s trProject, strAtRiskCode)
RiskCodeOld.Che cked = RiskCodeNew.Che cked
Else
UpdateProject(s trProject, strAtRiskCode, strComment)
End If
End If
Next
SubmitChanges(s trProject)
Catch ex As Exception
Trace.Write(ex. ToString)
End Try
End Sub
Here is what the code for ASPX page looks like:
<%@ Import namespace="Time " %>
<%@ Import namespace="Syst em.Data" %>
<%@ Register TagPrefix="uc1" TagName="footer " src="../footer.ascx" %>
<%@ Register TagPrefix="uc1" TagName="header " src="../header.ascx" %>
<%@ Page Language="vb" AutoEventWireup ="false"
Codebehind="Mai ntAtRiskProject s.aspx.vb"
Inherits="Time. MaintAtRiskProj ects"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>MaintAtR iskProjects</title>
<meta content="Micros oft Visual Studio .NET 7.1" name="GENERATOR ">
<meta content="Visual Basic .NET 7.1" name="CODE_LANG UAGE">
<meta content="JavaSc ript" name="vs_defaul tClientScript">
<meta content="http://schemas.microso ft.com/intellisense/ie5"
name="vs_target Schema">
<LINK href="../master.css" type="text/css" rel="stylesheet ">
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id="MaintAtRisk ProjectsFrm" method="post" runat="server">
<uc1:header id="PageHeader " runat="server"> </uc1:header>
<P><asp:dropdow nlist id="ddlProject " style="Z-INDEX: 101; LEFT: 16px;
POSITION: absolute; TOP: 72px"
runat="server" OnSelectedIndex Changed="Displa yAtRiskProjInfo "
Font-Names="Lucida Console, Courier New"
Width="168px" autopostback="T rue"></asp:dropdownlis t></P>
<hr style="Z-INDEX: 102; LEFT: 8px; POSITION: absolute; TOP: 104px">
<asp:Button id="btnReport" style="Z-INDEX: 106; LEFT: 504px; POSITION:
absolute; TOP: 64px"
runat="server" Width="97px" Text="View Report"></asp:Button>
<asp:Button id="btnUpdate" style="Z-INDEX: 105; LEFT: 280px; POSITION:
absolute; TOP: 64px"
runat="server" Width="72px" Height="24px"
Text="Update"></asp:Button><asp :label id="lblProject " style="Z-INDEX: 104;
LEFT: 8px; POSITION: absolute; TOP: 128px"
runat="server" Width="160px" ForeColor="#CC0 000"
Height="24px"></asp:label><asp: datagrid id="dgAtRiskInf o" style="Z-INDEX:
103; LEFT: 184px; POSITION: absolute; TOP: 128px"
runat="server" Width="385px" Height="160px" ShowFooter="Fal se"
AutoGenerateCol umns="False">
<AlternatingIte mStyle BackColor="Mist yRose"></AlternatingItem Style>
<ItemStyle HorizontalAlign ="Right"></ItemStyle>
<HeaderStyle ForeColor="#CC0 000" BackColor="Silv er"></HeaderStyle>
<Columns>
<asp:TemplateCo lumn>
<ItemTemplate >
<asp:TextBox ID="txtAtRiskCo de" Text='<%
#Container.Data Item("AtRiskCod e") %>' Runat=server Visible=False>
</asp:TextBox>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn>
<ItemTemplate >
<asp:CheckBox ID="chkCodeOld " Checked='<%
#Container.Data Item("RiskCodeF lag") %>' Runat="server" Visible=False>
</asp:CheckBox>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="Che ck/Uncheck">
<ItemTemplate >
<asp:CheckBox ID="chkCodeNew " Checked='<%
#Container.Data Item("RiskCodeF lag") %>' Width="15px" Runat=server>
</asp:CheckBox>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="Des cription">
<ItemTemplate >
<asp:Label ID="lblDescript ion" text='<%
#Container.Data Item("Descripti on") %>' width="250px" runat=server>
</asp:Label>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="Com ment">
<ItemTemplate >
<asp:TextBox ID="txtComment " Text='<% #Container.Data Item("Comment")
%>' Width="400px" Runat=server>
</asp:TextBox>
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:datagrid></form>
</body>
</HTML>
Please help.. Can't figure out what is going on.
Thanks,
Biva
--------------------------------------------------------------------------------
-------------------------------------------------------------------------------- 6 6425
"Biva" <bi***********@ redprairie.com> wrote in message
news:41******** *************** @news.twtelecom .net... Hello All, Please help. I get the following error from my webpage:
System.InvalidC astException: Specified cast is not valid. at Time.MaintAtRis kProjects.Updat eProject(String Project, String AtRiskCode, String Comment)
Code for UpdateProject(S tring Project, String AtRiskCode, String Comment) is:
....
Please help.. Can't figure out what is going on.
I can't figure out what's going on either, since you did not tell us which
line was causing the error.
This sort of thing happens frequently when a database column contains NULL.
NULL is not a value, so if you try to treat it as a string, you'll get the
invalid cast exception.
John Saunders
John,
My frustration is that it works on my PC that has Framework 1.1.
But when I move it to production that has framework 1.0, it does not
work.
I have the backward compatibility turned on, so it should work.
Since it is on production, i don't have an easy way to debug.
All I could do was set debug=true on web.config and look at the
trace.axd to get that error.
Is there an easy way for me to find out what line is actually giving me
that error?
thanks...
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
"sqlgirl" <sq*****@devdex .com> wrote in message
news:ur******** ******@tk2msftn gp13.phx.gbl...
John, My frustration is that it works on my PC that has Framework 1.1. But when I move it to production that has framework 1.0, it does not work. I have the backward compatibility turned on, so it should work. Since it is on production, i don't have an easy way to debug. All I could do was set debug=true on web.config and look at the trace.axd to get that error. Is there an easy way for me to find out what line is actually giving me that error?
I don't know, but this kind of thing is a reason to develop on the platform
you're going to use in production.
John Saunders
Here is my DeleteProject method.
Dim rows() As AtRiskProjectsD S.AtRiskProject sRow =
AtRiskProjDS.At RiskProjects.Se lect(AtRiskProj DS.AtRiskProjec ts.ProjectCo
lumn.ColumnName & "= '" & strProject & "' AND " &
AtRiskProjDS.At RiskProjects.At RiskCodeColumn. ColumnName & "= '" &
strAtRiskCode & "' ")
is the statement that is not being liked for some reason.
Sub DeleteProject(B yVal Project As String, ByVal AtRiskCode As String)
Try
Dim strProject As String = Project
Dim strAtRiskCode As String = AtRiskCode
Dim rows() As AtRiskProjectsD S.AtRiskProject sRow =
AtRiskProjDS.At RiskProjects.Se lect(AtRiskProj DS.AtRiskProjec ts.ProjectCo
lumn.ColumnName & "= '" & strProject & "' AND " &
AtRiskProjDS.At RiskProjects.At RiskCodeColumn. ColumnName & "= '" &
strAtRiskCode & "' ")
Trace.Write("pr oj1: " & strProject & ", code1: " &
strAtRiskCode)
Dim r As AtRiskProjectsD S.AtRiskProject sRow
If rows.Length <> 0 Then
r = rows(0)
r.Delete()
End If
Catch ex As Exception
Trace.Write(ex. ToString)
End Try
End Sub
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
"sqlgirl" <sq*****@devdex .com> wrote in message
news:Ou******** ******@TK2MSFTN GP09.phx.gbl... Here is my DeleteProject method. Dim rows() As AtRiskProjectsD S.AtRiskProject sRow = AtRiskProjDS.At RiskProjects.Se lect(AtRiskProj DS.AtRiskProjec ts.ProjectCo lumn.ColumnName & "= '" & strProject & "' AND " & AtRiskProjDS.At RiskProjects.At RiskCodeColumn. ColumnName & "= '" & strAtRiskCode & "' ")
Ok, if there's something on that line that ASP.NET doesn't like, then
simplify it:
Dim projectColumnNa me as String =
AtRiskProjDS.At RiskProjects.Pr ojectColumn.Col umnName
Dim atRiskCodeColum nName As String =
AtRiskProjDS.At RiskProjects.At RiskCodeColumn. ColumnName
Dim query As String = projectColumnNa me & "= '" & strProject & "' AND " &
atRiskCodeColum nName & "= '" & strAtRiskCode & "' "
Dim rows() As AtRiskProjectsD S.AtRiskProject sRow =
AtRiskProjDS.At RiskProjects.Se lect(query)
Try that and tell us which line has the problem.
John Saunders
I had defined rows() variable as my dataset.datatab lerowtype.
eg.
Dim rows() As AtRiskProjectsD S.AtRiskProject sRow
Framework 1.0 did not like it.
After I changed the rows() variable to simple datarow type as shown
below, it worked fine.
Dim rows() As datarow
Just so if anyone has this problem in the future.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: karunakar |
last post by:
Hi All
Here iam getting this Error "Specified cast is not valid."
My Project has Onc solution diffrent class libarary In that solution DALfactory solution iam getting this error
I was calling this function in DALFactory class library(this library generate the DAL.dll)
Another class library has this function
public SecurityInfo Login(string username, string password)
{
|
by: Michael Moreno |
last post by:
Hello,
I am failing to understand why I get an invalid cast exception with
this very simple code.
I have derived the EventArgs class as follow:
public class StringArgs : System.EventArgs
{
public string Msg;
|
by: Arjen |
last post by:
Hello,
Does somebody haves a solution for this?
Thanks!
Line 74: if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem) {
|
by: Miguel Angel Dinelli |
last post by:
I´m trying to execute a project and I get this error
System.InvalidCastException: Specified cast is not valid.
I found in microsoft some Q in 327287, but I not sure how make to solution
it.
I apreciate your help
tks
|
by: Roy Lawson |
last post by:
I have no idea what is going on here. I wrote a simple application in
VB.NET to generate a Crystal Report, and I am now trying to move it to
ASP.NET with Crstal Enterprise. I wish I could tell you how the
report works...but I can't even get past connecting to the database
:-)
I use the typical:
Dim oConnection As New SqlConnection(strCon)
Dim cmdText As String = "SELECT * FROM viewLogin WHERE " & _
| |
by: Miriam |
last post by:
Hello,
I am trying to edit an xml file. I am using Visual Studio .NET 2003.
When I click on the "Data" tab (instead of the XML tab) to enter in
data like in excel, the following occurs: If I try to edit/enter
data, I get this error:
InvalidCastException: Specified cast is not valid
I AM able to edit the xml from the xml tab, just not the data tab. A
|
by: DOTNET |
last post by:
Hi,
Anybody help me regarding this error:
I am assigning the values to the session variables when the button is
clicked and passing these session variables to the next page and when I am
printing these session variables they are printing. After that I am
assigning these things in hidden object and in the form submit action I am
receiving these hidden values like the following:
|
by: QA |
last post by:
I am using a Business Scorecard Accelarator in a Sharepoint Portal 2003
using SQL Server 2005
I am getting the following error:
Error,5/7/2005 10:50:14 AM,580,AUE1\Administrator,"Specified cast is
not
valid.","Microsoft.BusinessIntelligence.Scorecard.ScorecardException:
Specified cast is not valid. --->
Microsoft.BusinessIntelligence.Scorecard.ScorecardException: Specified
cast is not valid. ---> System.InvalidCastException: Specified...
|
by: Gamma |
last post by:
I'm trying to inherit subclass from System.Diagnostics.Process, but
whenever I cast a "Process" object to it's subclass, I encounter an
exception "System.InvalidCastException" ("Specified cast is not
valid"). How do I fix it ?
using System.Diagnostics;
..
..
class NewProcess: Process
{
|
by: rsdev |
last post by:
Hi,
I have an InvalidCastException which is completely puzzling me. I have checked all the members in the stored procedure against my data provider and seems to be ok. Also in the stack trace it says ProcessRequestMain... +3742??
Here's the error;
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |