| | |
Object Null Reference ??
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
Hi There
I get the following error when clicking on btn
This code works perfectly on some machines but does not work on others
Here is the stored procedure
Does anyone know why i get this error ??? I am using SQL server 2005 developer edition, visual studio 2008 C#
Thanks in advance
I get the following error when clicking on btn
This code works perfectly on some machines but does not work on others
C# Syntax (Toggle Plain Text)
protected void btnSave_Click(object sender, EventArgs e) { if (btnSave.Text.ToUpper() == "CREATE") this.InsertInvoice(); else if (btnSave.Text.ToUpper() == "SAVE CHANGES") this.UpdateInvoice(); } private void InsertInvoice() { String sqlCommand = String.Empty; DataSet result = null; //Create the command. sqlCommand = String.Format("EXEC nga_InsertPaymentInvoice {0}, '{1}', {2}, '{3}', '{4}', '{5}'", 1, ddVendors.Text, "0.14", txtReasonForPayment.Text, txtAuthoriser.Text, DateTime.Now.ToLongDateString()); //Execute the command and get the new invoice id. result = m_dbHandler.SmartGetDataSet(sqlCommand); //Redirect. base.Response.Redirect(String.Format("FulfillmentPayment.aspx?Command=Edit&InvoiceId={0}", result.Tables[0].Rows[0][0])); }
Here is the stored procedure
ASP.NET Syntax (Toggle Plain Text)
set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER PROCEDURE [dbo].[nga_InsertPaymentInvoice] @invoiceType INT, @couplingEntity NVARCHAR(256), @taxRate FLOAT, @reasonForPayment TEXT, @authoriser NVARCHAR(256), @dateCreated DATETIME AS BEGIN INSERT INTO nga_PaymentInvoices VALUES (@invoiceType, @couplingEntity, @dateCreated, @taxRate, @reasonForPayment, @authoriser); SELECT InvoiceId FROM nga_PaymentInvoices WHERE invoiceType=@invoiceType AND couplingEntity=@couplingEntity AND dateCreated=@dateCreated AND AtTimeTaxRate=@taxRate AND Authoriser=@authoriser; END
Does anyone know why i get this error ??? I am using SQL server 2005 developer edition, visual studio 2008 C#
Thanks in advance
Last edited by cVz; Mar 3rd, 2009 at 3:52 am.
Delphi & C# programmer deluxe...
c# Syntax (Toggle Plain Text)
result = m_dbHandler.SmartGetDataSet(sqlCommand);
That line must be handling an exception and returning a null. You need to check if (result == null) then the operation was not sucessful.
c# Syntax (Toggle Plain Text)
if (result == null) Response.Redirect("~/error.aspx");
![]() |
Similar Threads
- CookieContainer Returning NULL (C#)
- Null Reference Exception Unhandled (VB.NET)
- Runtime classname of null object (Java)
- Npe please help!!! (Java)
- Object reference not set to an instance of an object (ASP.NET)
- sql data pull with no result gives Object reference not set exception (VB.NET)
- Newbie question:Unable to pass reference to an object (C#)
- another question (C++)
- Urgent Help Needed!!!! Plzzz (Java)
- Java practice questions (Java)
Other Threads in the ASP.NET Forum
- Previous Thread: Plz.. how to send nearly 700 e-mail at a time in asp.net
- Next Thread: why use @reference directive
| Thread Tools | Search this Thread |
.net activexcontrol advice ajax alltypeofvideos appliances asp asp.net bc30451 beginner bottomasp.net box browser button c# cac checkbox click commonfunctions control css dataaccesslayer database datagridview datagridviewcheckbox datalist deadlock deployment development dgv dialog dropdownlist dynamic dynamically edit embeddingactivexcontrol expose fileuploader fill findcontrol flash formatdecimal formview gridview gudi iframe iis javascript listbox login microsoft mono mouse mssql multistepregistration news novell numerical objects opera panelmasterpagebuttoncontrols radio redirect registration relationaldatabases reportemail rotatepage save schoolproject search security sessionvariables silverlight smartcard smoobjects software sql-server sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visualstudio web webapplications webdevelopemnt webdevelopment webprogramming webservice xsl youareanotmemberofthedebuggerusers






