object reference not set to an instance of an object

Oct 3 2008 5:53 AM
When write this code...
===================
/SqlConnection Connection = Connection.Open();
            SqlCommand Comm = new SqlCommand();
            //Comm.Connection = Conn;
             Comm.CommandType = CommandType.Text;
            Comm.CommandText = "Insert Into customer (Emailid,Password,Userid,Add1,State,City,Pin,Title,Fname,Lname,Gender,Dob,Mobile,Regidate) " + " values('" + txtEmailid.Text + "','" + MyPwd + "','" + txtEmailid.Text + "','" + txtAdd1.Text + "','" + cmbState.SelectedItem.Text + "','" + txtCity.Text + "'," + txtPin.Text + ",'" + CmbTitle.SelectedItem.Text + "','" + txtFname.Text + "','" + txtLname.Text + "','" + cmbGender.SelectedItem.Text + "','" + BodDate.SelectedDate.Date + "'," + txtMobile.Text + ",'" + System.DateTime.Today + "')";
            Comm.ExecuteNonQuery();
            //SqlConnection Connection = Connection.Close();

            Adpt = new SqlDataAdapter("select * from customer", Connection);
            Dataset1 = new DataSet();
            Adpt.Fill(Dataset1, "customer");

            EmptyControls();

================================
the insert in to qrety line in command.commantext will give this error
object reference is not set to an instance of the object
plz solve my problem as early as possible..


Thanks in advacne
Shah Shishir

Answers (2)