Works on Client, doesn't work on Deployment server

I'm trying to deploy an application that has been tested and works fine on the client but now suddenly doesn't work on the server at all.  Its very bizarre.  If anyone has an ideas, as I'm pulling my hair out.

This is the error:

Server Error in '/Admin' Application.

Object reference not set to an instance of an object.

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.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 422:        myCommand.Parameters.Add(New SqlParameter("@RegFName", _
Line 423:           SqlDbType.VarChar, 50))
Line 424:        myCommand.Parameters("@RegFName").Value = txtFName.Text
Line 425:
Line 426:        myCommand.Parameters.Add(New SqlParameter("@RegLName", _

Source File: F:\domains\SalesCart_Express\wwwroot\Admin\panel\LicenseMgr.aspx.vb    Line: 424

This is the code for everything up to that area.

    Sub InsertData()
        'Insert New Registration information into License Database
        '[SetupID], [StoreID], [CompanyName]
        Dim MyLicense As Label = GridView1.SelectedRow.FindControl("LicenseLabel1")
        Dim MyDomain As Label = GridView1.SelectedRow.FindControl("DomainLabel1")

        Dim txtFName As Label = DataList1.FindControl("FNameLabel")
        Dim txtLName As Label = DataList1.FindControl("LNameLabel")
        Dim txtAddr As Label = DataList1.FindControl("AddressLabel")
        Dim txtCity As Label = DataList1.FindControl("CityLabel")
        Dim cmbState As Label = DataList1.FindControl("StateOrProvinceLabel")
        Dim txtZip As Label = DataList1.FindControl("PostalCodeLabel")
        Dim cmbCountry As Label = DataList1.FindControl("CountryLabel")
        Dim txtEmail As Label = DataList1.FindControl("EmailAddressLabel")

        Dim myConnection As SqlConnection
        Dim myCommand As SqlCommand
        Dim insertCmd As String
        Dim today As DateTime
        Dim currYr As Integer
        Dim currMonth As Integer
        Dim currDay As Integer
        Dim lastDate As DateTime
        '      Dim trialEndDate As String

        today = System.DateTime.Now.Date
        currYr = System.DateTime.Now.Year
        currMonth = System.DateTime.Now.Month
        currDay = System.DateTime.Now.Day

        lastDate = System.DateTime.Now.AddDays(CInt(GetProdTerm()))
        lastDate = String.Format("{0:d}", lastDate)

        myConnection = GetSQLConnection()

        ' Build a SQL INSERT statement string for all the input-form
        ' field values.
        insertCmd = "INSERT INTO Registration values (@RegSerial," _
           & "@RegDomain, @RegProduct, @RegDate, @RegSubStart," _
           & "@RegSubEnd, @RegActive, @RegFName, @RegLName, @RegAddr," _
           & "@RegCity, @RegState, @RegZip, @RegCountry, @RegEmail," _
           & "@RegReminder, @RegInactiveEmail, @RegVer);"

        ' Initialize the SqlCommand with the new SQL string.
        myCommand = New SqlCommand(insertCmd, myConnection)

        ' Create new parameters for the SqlCommand object and
        ' initialize them to the input-form field values.
        myCommand.Parameters.Add(New SqlParameter("@RegSerial", _
           SqlDbType.VarChar, 50))
        myCommand.Parameters("@RegSerial").Value = MyLicense.Text

        myCommand.Parameters.Add(New SqlParameter("@RegDomain", _
           SqlDbType.VarChar, 50))
        myCommand.Parameters("@RegDomain").Value = MyDomain.Text

        myCommand.Parameters.Add(New SqlParameter("@RegProduct", _
           SqlDbType.VarChar, 50))
        myCommand.Parameters("@RegProduct").Value = Expressver

        myCommand.Parameters.Add(New SqlParameter("@RegDate", _
           SqlDbType.DateTime, 8))
        myCommand.Parameters("@RegDate").Value = today

        myCommand.Parameters.Add(New SqlParameter("@RegSubStart", _
           SqlDbType.DateTime, 8))
        myCommand.Parameters("@RegSubStart").Value = today

        myCommand.Parameters.Add(New SqlParameter("@RegSubEnd", _
           SqlDbType.DateTime, 8))
        myCommand.Parameters("@RegSubEnd").Value = lastDate

        myCommand.Parameters.Add(New SqlParameter("@RegActive", _
           SqlDbType.VarChar, 50))
        myCommand.Parameters("@RegActive").Value = "Yes"

        myCommand.Parameters.Add(New SqlParameter("@RegFName", _
           SqlDbType.VarChar, 50))
        myCommand.Parameters("@RegFName").Value = txtFName.Text

*** CRASH***

I can see that txtFName has a value in the html source view of the page that calls this subroutine.  And, I'm binding the data beforehand.  This subroutine is called from another routine that handles a button push event.

Here is the html source view of the page before the button is pressed where the datalist1 is shown.

<span id="ctl00_ContentPlaceHolderMain_DataList1_ctl00_FNameLabel">Michael</span>

It works 100% on the client and crashes on the server?????

5/8/2007 8:03:59 PM 72751 articles. 3 followers. Follow

7 Replies

Similar Articles

[PageSpeed] 45

Hello my friend,

I think I can help, but I will need to see the source code of the aspx page as well.  Looking at your code, something seems odd.  A DataList is a control that should contain many rows, so if you expect it to only have one row and it contains a label called FNameLabel, you would do something like this to get the control of the first row (row 0): -


instead of DataList1.FindControl("FNameLabel")

Kind regards



5/8/2007 8:26:37 PM

It should be easy to debug. Just to see if the value of your txtFName Is Nothing or not. If Is Nothing, that means there is no such a control named FNameLabel in your DataGrid.

Or, you can check on broswer:

Dim  txtFName  As Label = CType(DataList1.FindControl("FNameLabel"), Label)
If txtFName Is Nothing Then

   Response.Write("No Lable")


   Response.Write("Lable Found")
End If

"Object reference not set to an instance of an object"
5/8/2007 9:18:35 PM

If you put debug code in for this value, its Null on the Server environment but is not null on the client development environment.  The other conceivable difference is the client development environment the database is SQL Express 2005 whereas on the server its SQL 2000.

The datalist control was used just because its convenient, there is really just One row of data ever shown because of the SQL statement.

If I use


it no longer crashes.  Its not saving the data its still not working 100%.

Is there a way to display the final sql statement of a SQLCommand where you are using @variable  names?  I want to double check what the sql statement is...

5/9/2007 2:32:33 PM

Try put the loop of your datalist inside your sub InsertData()

For Each item As DataListItem In DataList1.Items

    Dim txtFName As Label = item.FindControl("FNameLabel")
    If(txtFName IS Not Nothing)

        'Do all save coding here

    End If 



I quess you can save the first row (0) but other rows because you didn't loop through your DataList.

"Object reference not set to an instance of an object"
5/9/2007 4:36:05 PM
No, there is only one row of data.  The SQL command is not executing at all.  Is there a way to show the Response.write (InsertCommand.toString) but show the @FName and other @values as the completed SQL would be interpreted to view the final SQL statement?
5/9/2007 5:57:33 PM

1). If you only have one record in the DataList, you can use (0) for the data. However, it is not a good practice. If you have more than one records later, you code will not work anymore.

2). I didn't see your code to execute your command. Try put MyCommand.ExecuteNonQuery() at the last on your code.

"Object reference not set to an instance of an object"
5/9/2007 7:48:02 PM
Scotty's suggestion seems to have fixed this....
5/10/2007 1:58:23 PM

Similar Artilces:

Spellchecker doesn't work: no error, just doesn't work
Hey all. This is only happening with one person. It's all GW7 no SP. has worked fine before. Anyway when they type along it doesn't catch that spelling and it doesn't fire up spell check before it's sent like it is checked off to do. It does nothing. It just sends it when you click send; no error, nothing. I did a rebuild, analyze/fix. I have it set at all levels for this user. any ideas Mark, well, I'd try a more recent client version first. GW7 was less than stellar before SP1. Uwe -- Novell Support Connection Volunteer SysOp Please don...

Urgent: AutoCompleteExtender doesn't work/Updatepanel doesn't work
This is my code for the AutoCompleteExtender <asp:textbox id="txtQuickSearch" runat="server" CssClass="inputText" style="width:145px; "></asp:textbox> <atlas:AutoCompleteExtender runat="server" ID="acSearch"> <atlas:AutoCompleteProperties TargetControlID="txtQuickSearch" Enabled="True" ServicePath="http://localhost/Sony.BusinessSuite.Web.UI/AtlasServices/MasterData.asmx" ServiceMethod="GetAllModels" minimumprefixlength="2" /> </atlas:AutoCompleteExtender> When i start typing fiddler shows: # Result Host URL Body Caching Content-Type User-...

Freenx doesn't work, NX doesn't work with compiz. Questions
FreeNX just doesn't work. NX from nomachine installed well, but I guess that limits me to two logins? NX doesn't work with compiz, tho, at least from machines not running compiz. So no great surprise. :-) Is there any way to run startkde that disables compiz and uses kwin? Alternatively, hows the easiest way to handle alternative logins? I could link the two documents folders together, but then I'd have problems with file permissions. I'm just looking for ideas here, I could live with two logins. -- dougnc -------------------------------------------...

Can't get the Web Controls to work.. The Build.Bat file doesn't work? HELP>> ARGGG>.
Hi.. I was wanting to use the IE Web Controls, the Tab Strip, etc, and play with it.. Since I have IIS 5, I thought I'd copy them there using the Read me.txt instructions and then copy to a dev server that I use at a web host.. Well, everything worked except the Build file doesn't build the Microsoft.UI.Webcontrols.DLL file? When I try to run it by double clicking on it, it runs really fast in  the DOS window, but I can't see what it says and it closes.. So I tried to do so manually and I received an error that the "cse.exe is not recognized as an internal or external command or batch...

client install doesn't work and can't uninstall client
Help! I installed Groupwise 6.5 client on a freshly formatted workstation. All seemed to go normal, except when i tried to run Groupwise i get the following... Groupwise is not properly installed. The Groupwise components could not be initialized. Please run groupwise setup, or contact your systme administrator. so i then tried to uninstall the the client and i get this... The log file "C:\windows\system32\delsl2.isu" is not valid or the data has been corrupted. Uninstallation will not continue. so i then tried to just do an install anyway, and i end up...

keeps making me download update, but, update doesn't work, makes me download update, update doesn't work..................
Name: donald davis Email: galenachefatyahoodotcom Product: Firefox Summary: keeps making me download update, but, update doesn't work, makes me download update, update doesn't work.................. Comments: That's pretty much the whole deal. An update screen pops up, I update, the update doesn't take and the next time I use firefox mozilla the same thing happens over and over and over. Thanks Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20070309 Firefox/ ...

Installation 'Sybase DataWindow PS' printer on W98 doesn't work (so PDF export can't work either)
I have a problem with export DataWindow content to PDF on W98 systems. (I don't have any problem with PDF export on other systems like as WINNT, W2K, WXP). I found out that the problem is in the Sybase DataWindow PS printer. It looks like installed but it DOESN'T WORK on W98. When I try print something on this printer then no PostScript file is created. So I tried manual installation of it but it occurs an error during manual installation (I used description of instalation from Bruce Armstrong). The error said that printer driver (PSCRIPT.DLL) can't be loaded. I use...

Groupwise Client as a POP3 client--SMTP doesn't work as a 'send'
Our company was just acquired (never happens these days) by another company that has an exchange server. We're trying to keep our GW for at least the near future and want to just 'POP' and SMTP through the Exchange server. I can receive messages no problem, but can't send. When I send, I get the super-duper descriptive error message, 'Service not Available'. How do I track down where the SMTP is failing? I can send from Outlook Express, so I assume it's something within the Groupwise client that is having issues with the SMTP service on the Exchange serve...

Works on locaol Machine but doesn't work on live server
I created an atlas page:<cc1:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True"><Services><cc1:ServiceReference Path="AtlasServicestesting.asmx" Type="text/javascript" /></Services></cc1:ScriptManager><table border="0" cellspacing="0" cellpadding="0"><tr><td align="left" valign="top" colspan="3" style="height: 8px"><img src="../../images/spacer.gif" width="329" height="8&...

Same app in two application directories
Hi All, I'm developing an app on my local machine.  I have had Visual Studio create an application directory under "Default Web Site", and I have also created an application directory myself via inetmgr (IIS7 on Vista).  The directory created by VS works perfectly, but the directory which I created manually doesn't - every page I load returns a "could not load type" error.  The exact same files exist in both directories (I literally copied them from my dev directory to the one I created), so I know it's not the source files themselves.&...

'Tab' control 's visible doesn't work.Why?
I use tab control in my applition. And I set visible=false, but it doesn't work. my code is: ----------------------------------------------- <asp:ScriptManager ID="ScriptManager1" runat="server" />  <div>   <ajaxToolkit:TabContainer runat="server" ID="Tabs" Height="138px" ActiveTabIndex="0"    Width="402px">    <ajaxToolkit:TabPanel runat="server" ID="Panel1" HeaderText="Tab1" Visible="f...

user control works on page_load doesn't work on button click
Hello, I need some help.  I have a user control within a datalist that works fine upon entry  to my page (page_load) for the first time, but when I try to rebind the datalist via a push button I get nothing, a blank instance of the control is created.  Here is the code. My main page: <%@ Page Language="VB" Debug="true" MasterPageFile="~/site.master"%><%@ Register TagPrefix="custom" TagName="custRoute" Src="test_route_summary.ascx" %><%@ import Namespace="System" %><%@ import Namespace="System.Data" %><%@ import Namespace="System.Data.OleD...

Forms Authentication doesn't work on remote server but works locally.. why?
I can't seem to figure this out. The same code base works on my localhost but not on the remote server. Forms Authentication keeps timing out remotely. Here's my web.config for the virtual root. <authentication mode="Forms"> <forms loginUrl="ui/Consumer/Registration/Registration.aspx" name=".dailyspecials_cookie" path="/" timeout="700000" protection="All"> </forms> </authentication> and if my "secret" directory, my web.config looks like this...

getElementByID doesn't work for server controls
Ok - I'm trying to access a control using the getElementByID method in javascript but I'm also trying to use the .NET infrastructure to save the state of controls on the form (which means they have to be server controls) but I'm getting an error looking up any controls by ID in javascript if they are specified as being a server control. Why is that? Does your server control reside on a user control? If so, ASP.NET will give the control a new client-side ID (basically it prepends the ID of the user control instance to the ID of the server control). View your source HTML and see if the ...

Web resources about - Works on Client, doesn't work on Deployment server -

Resources last updated: 1/13/2016 9:37:23 PM