ERRO
Server Error in '/' 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 55: da.Fill(ds);
Line 56:
Line 57: lblName.Text = dt.Rows[0]["Name"].ToString();
Line 58: lblName1.Text = dt.Rows[0]["Interest"].ToString();
Line 59: // LabelLastLogin.Text = dt.Rows[0]["LastLogin"].ToString();
CODE
if (!Page.IsPostBack)
{
SuggestedAd(int.Parse(Request.QueryString["Id"].ToString()));
}
}
private void SuggestedAd(int Id)
{
string str = ConfigurationManager.ConnectionStrings["SocailAPP"].ConnectionString;
string getADPOST = "UserProfile";
using (SqlConnection con = new SqlConnection(str))
{
con.Open();
using (SqlCommand cmd = new SqlCommand(getPOST, con))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Id", Request.QueryString["Id"].ToString());
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
ADImage1.ImageUrl = "~/UserImage/" + dt.Rows[0]["ImageName"].ToString();
lblName.Text = dt.Rows[0]["Name"].ToString();
lblName1.Text = dt.Rows[0]["Interest"].ToString();
// LabelLastLogin.Text = dt.Rows[0]["LastLogin"].ToString();
lblCreated.Text = dt.Rows[0]["AboutUs"].ToString();
// lblProfession.Text = dt.Rows[0]["Email"].ToString();
// lblCountry.Text = dt.Rows[0]["Address"].ToString();
}
}