Click here to Skip to main content
15,913,927 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: capture and save user id when new record created in asp.net mvc Pin
Member 1115681016-Oct-14 7:51
Member 1115681016-Oct-14 7:51 
GeneralRe: capture and save user id when new record created in asp.net mvc Pin
David Mujica17-Oct-14 8:36
David Mujica17-Oct-14 8:36 
GeneralRe: capture and save user id when new record created in asp.net mvc Pin
Member 1115681020-Oct-14 5:28
Member 1115681020-Oct-14 5:28 
Questionusing content page controls with external js file ? Pin
jayesh_n14-Oct-14 19:07
jayesh_n14-Oct-14 19:07 
AnswerRe: using content page controls with external js file ? Pin
jkirkerx15-Oct-14 11:08
professionaljkirkerx15-Oct-14 11:08 
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 

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.