Click here to Skip to main content
15,887,214 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionEnableEventValidation="false" OR EnableEventValidation="true" Pin
Saeed Ansarinejad14-Oct-14 8:06
Saeed Ansarinejad14-Oct-14 8:06 
AnswerRe: EnableEventValidation="false" OR EnableEventValidation="true" Pin
Kornfeld Eliyahu Peter14-Oct-14 8:20
professionalKornfeld Eliyahu Peter14-Oct-14 8:20 
GeneralRe: EnableEventValidation="false" OR EnableEventValidation="true" Pin
Saeed Ansarinejad14-Oct-14 8:46
Saeed Ansarinejad14-Oct-14 8:46 
Questionpopup issue for showModalDialog Pin
Archana Gaikwad14-Oct-14 3:26
Archana Gaikwad14-Oct-14 3:26 
Suggestion[Repost] popup issue for showModalDialog Pin
Richard Deeming14-Oct-14 4:02
mveRichard Deeming14-Oct-14 4:02 
QuestionPassing GUID to a function Pin
Huma Ansari13-Oct-14 20:18
Huma Ansari13-Oct-14 20:18 
AnswerRe: Passing GUID to a function Pin
Mycroft Holmes13-Oct-14 20:44
professionalMycroft Holmes13-Oct-14 20:44 
AnswerRe: Passing GUID to a function Pin
Richard Deeming14-Oct-14 1:45
mveRichard Deeming14-Oct-14 1:45 
Huma Ansari wrote:

SqlCommand cmd1 = ...
cmd.Parameters.Add(...

Those are two different variables. You're getting a NullReferenceException because you haven't initialized the cmd variable.

Change your code to either:
C#
cmd1.Parameters.Add("@ApplicationID", SqlDbType.UniqueIdentifier).Value = appIDValue;

or:
C#
cmd1.Parameters.AddWithValue("@ApplicationID", appIDValue);



Other comments:
The SqlDataAdapter class takes care of opening and closing your connection for you, so there's no need to explicitly open the connection before calling the Fill method.

The SqlCommand constructor has already assigned the connection; there's no need to set da1.SelectCommand.Connection to the same connection instance.

You should also look at wrapping your connection and command objects in using blocks, and avoid storing them in fields.
C#
using (SqlConnection con = new SqlConnection(connectionString))
using (SqlCommand cmd = new SqlCommand("[sp_ReadPreviousProperty]", con))
{
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.AddWithValue("@ApplicationID", appIDValue);
    
    SqlDataAdapter da1 = new SqlDataAdapter();
    da1.SelectCommand = cmd;
    
    DataSet ds1 = new DataSet();
    da1.Fill(ds1, "tblPropertyMaster");
    return ds1;
}


Finally, using sp_ as the prefix for a stored procedure is not a good idea:
http://sqlperformance.com/2012/10/t-sql-queries/sp_prefix[^]



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


QuestionMy code is not working while using with updatepanel.The ddl selected item it coming blank whiule printing before using update panel it was coming. Pin
ank065713-Oct-14 19:35
ank065713-Oct-14 19:35 
QuestionIs there a way to capture all the page records in jqgrid when exporting to excel Pin
parkway13-Oct-14 9:15
parkway13-Oct-14 9:15 
AnswerRe: Is there a way to capture all the page records in jqgrid when exporting to excel Pin
devvvy13-Oct-14 9:32
devvvy13-Oct-14 9:32 
QuestionRegarding Self hosting SignalR Application in Win Service Pin
Tridip Bhattacharjee13-Oct-14 5:20
professionalTridip Bhattacharjee13-Oct-14 5:20 
QuestionHow to embed a video in my c# based dot net website which should be compatible in all browsers especially chrome. Pin
Member 1107698013-Oct-14 1:15
Member 1107698013-Oct-14 1:15 
Questionasp.net web service error "Microsoft.Web.Services3.Security.SecurityFault: Header http://schemas.xmlsoap.org/ws/2004/08/addressing:Action for ultimate recipient is required but not present in the message." Pin
rafay ansar12-Oct-14 10:32
rafay ansar12-Oct-14 10:32 
AnswerRe: asp.net web service error "Microsoft.Web.Services3.Security.SecurityFault: Header http://schemas.xmlsoap.org/ws/2004/08/addressing:Action for ultimate recipient is required but not present in the message." Pin
jkirkerx12-Oct-14 11:48
professionaljkirkerx12-Oct-14 11:48 
QuestionHow to use JScript to get mouse position inside image? Pin
Troublesome Tommy10-Oct-14 10:19
Troublesome Tommy10-Oct-14 10:19 
AnswerRe: How to use JScript to get mouse position inside image? Pin
Troublesome Tommy11-Oct-14 6:57
Troublesome Tommy11-Oct-14 6:57 
QuestionSignalR - Jquery response - 304 error Pin
miss78610-Oct-14 4:28
miss78610-Oct-14 4:28 
QuestionHow to sms through asp.net website on mobile Pin
Harishankar Maurya9-Oct-14 19:21
Harishankar Maurya9-Oct-14 19:21 
AnswerRe: How to sms through asp.net website on mobile Pin
Mahinuddin11-Oct-14 1:53
Mahinuddin11-Oct-14 1:53 
QuestionGetting error while running Pin
Member 111411249-Oct-14 3:50
Member 111411249-Oct-14 3:50 
AnswerRe: Getting error while running Pin
Richard Deeming9-Oct-14 6:59
mveRichard Deeming9-Oct-14 6:59 
QuestionHow to maintain scroll position in chrome in Asp .Net Pin
Member 98439578-Oct-14 18:52
Member 98439578-Oct-14 18:52 
AnswerRe: How to maintain scroll position in chrome in Asp .Net Pin
Dominic Burford10-Oct-14 0:39
professionalDominic Burford10-Oct-14 0:39 
GeneralRe: How to maintain scroll position in chrome in Asp .Net Pin
Member 984395710-Oct-14 0:44
Member 984395710-Oct-14 0:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.