.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

CTYPE woes

Posted By:      Posted Date: August 27, 2010    Points: 0   Category :ASP.Net


I'm getting the old "Object reference not set to an instance of an object" error on this code:

nonqueryCommand.Parameters.Add("@comment", SqlDbType.VarChar, 500)

nonqueryCommand.Parameters("@comment").Value = CType(FormView1.Row.FindControl("CommentsLabel"), TextBox).Text

"CommentsLabel" is a textbox, despite it's name (and I've tried the CTYPE ot Label too).


Any ideas?



View Complete Post

More Related Resource Links

TypeConverter & Ctype


What is the difference between creating a TypeConverter and then converting an object to different type and using directly CType.

For example, what is the differece between these two:

1. Getting TypeConverter for a bitmap object and then converting it to byte[]

2. Directly using Ctype function to convert bitmap to byte[]

May sound basic, but pls help!!!!

SSAS2005 Writeback Woes

I wish to create a cube that can be written to. In MSAS2000 this was a doddle. However, in SSAS2005 all does not go so well. I have followed the instructions to the letter and also "Googled" how to do writeback in SSAS2005 but whenever I attempt to write to the cube (via ProClarity or XLCubed), I get the following error message "Errors in cell writeback. Cell writeback failed because one of the cells is secured. [Microsoft OLE DB Provider for Analysis Services 2005]". In order to proceed with my current project, it is important that I get writeback working correctly thus any advice will be appreciated.

web.config woes (membership)

Hi,I'm really struggling to set up membership for a new site and was hoping you could help me out. I've set up the database using aspnet_regsql.exe and I can connect to the db with the connectionstring I've set up. The WSAT, however, says "there's some kind of error" without specifying anything. The weird thing is that I've even tried copying the contents of an "old" site and just changing the parameters of the connection string, but still no luck.Thankful for any help!<?xml version="1.0"?><configuration> <connectionStrings> <add name="EcotechConnectionString" connectionString="Data Source=.\sqlexpress;Initial Catalog=Ecotech;Persist Security Info=True;User ID=EcotechUser;Password=prince44" providerName="System.Data.SqlClient" /> </connectionStrings> <system.web> <compilation debug="true" targetFramework="4.0" /> <authentication mode="Forms"> <forms loginUrl="~/Account/Login.aspx" timeout="2880"/> </authentication> <membership> <providers> <clear/> <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName=&quo

update panel woes... question for superstar AJAX gurus



This has got me completely confused... not sure if I've been at it too long and am missing something, or if this is a bug?

I have a webform with an AJAX update panel. In the panel there are 2 controls. One is a textbox, the other a listview.

I'm using the ClientScriptManager to take advantage of the "OnKeyUp" event to cause an autopostback.

When text is entered into the textbox, it runs the textchanged event, which puts data in the listview.

So far so good. All works fine with one exception.

Problem is that with IE8 the textbox loses focus on the SECOND text entry, even though it's specified in my code to focus on textbox after the textchanged event fires. And with Firefox, it doesn't cause the textchanged event to fire at all.

I don't get it??

Here's my code...

    Sub Page_load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load


        TextBox1.Attributes.Add("onKeyUp", Page.ClientScript.GetPostBackEventReference(TextBox1, ""))

    End Sub

    Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TextBox1.TextChanged

        Listbox1.Items.Add(New ListItem("ListboxItem", "ListboxValue"))

        TextBox1.Text = ""


many-to-many mssql schema, linq2sql, objectdatasource with SelectedIndex and delete woes


Hi All,

Here's the setup (excuse no code the setup doesn't post well):


table > link table > table (M:M)

link table is composite key with constraints


linq2sql DataContext of above schema


object datasource bound to Business Logic class (exposing the LINQ2SQL class methods) (ObjDs1)

ListView with DataSourceId to above objds (Lv1)

object datasource with control parameter aimed at above ListView SelectIndex (ObjDs2)

ListView aimed at above objds (Lv2)


select item in Lv1 > postback > Lv2 displays correct records for the M:M

On Delete (heres the fun) the delete fires, the data is deleted and constraints work (no error) BUT Lv2 still displays the deleted data...

I have called Page_PreRender Page.DataBind() just to make sure every control in the heirachy is rebound but to no avail...

I also noted that the OnDeleted event in the ObjDs2 has an AffectedRows of -1.... but the data is definitely deleted.


Correlation Token & Create Task Woes


I've created a State Machine work flow.
In State1 I create a Task (Task1). 
The workflow then goes to state State2 and State2  goes  back to State1.
Now when State1 runs through creating Task1 again I get a correlation token error.
I would like it to create a new Task1.

I'm not sure how I should be going about this.
The Correlation Token for Task1 is set to 'workflowToken'.  Inside the MethodInvoking code for Task1 I set
Task1_TaskID = Guid.NewGuid();
It creates a task the first time the flow passes through State1. It's on the second time that it passes through State1 that it crashes.

Am I doing anything wrong?

COM Event woes

After straightening out problems with my MSDN subscription (once again
:(,) hopefully I can now get some help with this issue.
I have made an in-process COM server that will have a number of clients
connecting to it. In one case, a client (written w/ unmanaged C++) will
always be the first to connect, thus creating the COM object, and call
an exposed method with a string parameter. I have this part working, so
my COM interface would seem to be correct.
In another case, some number of clients (written w/ managed .NET) will
subscribe to events that will be triggered by the value of the parameter
in the first case above (actually the result of an algorithm with said
parameter as input.) I'm having problems here.
I have the following questions:
1. Since the clients in case 2 will be .NET clients, is it necessary
that the COM server register itself with the ROT? That is, must
subsequent client connections (beyond the initial) make a call to
Marshal.GetActiveObject? I would think so, but experience in this area
is not deep.
2. The pattern that I'm trying to follow looks like this:

Ctype(sender, integer)


This is an ugly cast, but the code for this solution is already in a bad place, and it's not my job to fix. I'm curious if there is a way to determine whether a cast will be valid prior to casting.

Dim size As Integer = CType(sender, Integer)

'If cast was successful
'pass size to DAL
'if not pass something else

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