Asp.net Object reference not set to an instance of an object.

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.Sql;
using System.Data.SqlClient;


namespace Gids_Recritment
{
public partial class _Default : System.Web.UI.Page
{
SqlDataAdapter da = new SqlDataAdapter();
SqlConnection sqlcon = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=D:\My Documents\Visual Studio 2010\Projects\Gids\Gids\App_Data\Database1.mdf;Integrated Security=True;User Instance=True");
protected void Page_Load(object sender, EventArgs e)
{
txt_date.Text = DateTime.Today.ToString("dd/MM/yyyy");
}
protected void txt_resume_TextChanged(object sender, EventArgs e)
{

}
protected void txt_date_TextChanged(object sender, EventArgs e)
{
}
protected void ddl_cancity_SelectedIndexChanged(object sender, EventArgs e)
{

}
protected void ddl_canstate_SelectedIndexChanged(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
DateTime Date = new DateTime();
Date = System.DateTime.Now.Date;

if (txt_date.Visible)
{
if (txt_date.Text != null && txt_date.Text != string.Empty)
{
txt_date.Text = DateTime.Today.ToString("dd/MM/yyyy");
//Date = Convert.ToDateTime(txt_date.Text);
//Date = Convert.ToDateTime(Date.ToString("dd-MMM-yyyy"));
}
}

DataBinder ds = new DataBinder();
sqlcon.Open();
SqlCommand sqlcmd = new SqlCommand("INSERT INTO AddCandidate VALUES ('" + txt_date.Text + "," + txt_rcname.Text + "," + txt_vendor.Text + "," + txt_clname.Text + "," +
txt_clnumber.Text + "," + txt_canname.Text + "," + ddl_canstate.SelectedItem.Text + "," + ddl_cancity.SelectedItem.Text + "," + txt_canrate.Text + "," + txt_phnumber.Text + "," +
txt_email.Text + "," + txt_canskills.Text + "," + ddl_visastatus.SelectedItem.Text + "," +
ddl_availibilty.SelectedItem.Text + "," + txt_canempname.Text + "," + txt_canempsign.Text + "," +
txt_resume.Text + "')");
sqlcmd.Parameters.AddWithValue("@Date", txt_date.Text);
sqlcmd.Parameters.AddWithValue("@RecruiterName", txt_rcname.Text);
sqlcmd.Parameters.AddWithValue("@Vendor", txt_vendor.Text);
sqlcmd.Parameters.AddWithValue("@ClientName", txt_clname.Text);
sqlcmd.Parameters.AddWithValue("@ClientNumber", txt_clnumber.Text);
sqlcmd.Parameters.AddWithValue("@CanditateName", txt_canname.Text);
sqlcmd.Parameters.AddWithValue("@CandidateState", ddl_canstate.SelectedItem.Text);
sqlcmd.Parameters.AddWithValue("@CandidateCity", ddl_cancity.SelectedItem.Text);
sqlcmd.Parameters.AddWithValue("@CandidateRate", txt_canrate.Text);
sqlcmd.Parameters.AddWithValue("@PhoneNumber", txt_phnumber.Text);
sqlcmd.Parameters.AddWithValue("@Email", txt_email.Text);
sqlcmd.Parameters.AddWithValue("@CandidateSkills", txt_canskills.Text);
sqlcmd.Parameters.AddWithValue("@VisaStatus", ddl_visastatus.SelectedItem.Text);
sqlcmd.Parameters.AddWithValue("@Availability", ddl_availibilty.SelectedItem.Text);
sqlcmd.Parameters.AddWithValue("@CandidateEmployerName", txt_canempname.Text);
sqlcmd.Parameters.AddWithValue("@CandidateEmployerSignature", txt_canempsign.Text);
sqlcmd.Parameters.AddWithValue("@Resume", txt_resume.Text);
sqlcmd.ExecuteNonQuery();
sqlcon.Close();
if (fu_resume.HasFile)
{
fu_resume.SaveAs("D:\\My Documents\\Visual Studio 2010\\Projects\\Resumes\\" + fu_resume.FileName);
}
else
{

}
}
private void VALUES(string p)
{
throw new NotImplementedException();
}
public string filename { get; set; }
}
}
parth
Asked Jan 22, 2013
Edited Jan 22, 2013

If you are looking for a place to share your travel photos and stories, then try BigRoom.

well it sounds like an object hasn't been instantiated, you need to check the error line at runtime and see what has a value of null and get it instantiated
anders
Answered Apr 11, 2014

TIP: If it's not your answer to this question, please click "Leave a Comment" button under the question to communicate with the question owner.

Categories