login page
-
we completed the registration page in our project and whatever the details we have given in that registration page they are also going to update in the backend also. but whatever the username and password we have given in the registration page is not accepted by the login page.while giving the username and password it is showing the error like below object reference is not set to an instance of an object code i have written for registration page bal data = new bal(); data.FirstName = Text_FirstName.Text.Trim(); data.LastName = Text_LastName.Text.Trim(); data.Gender = Text_Gender.Text.Trim(); data.EmailId = Text_EmailId.Text.Trim(); data.UserName = Text_UserName.Text.Trim(); data.Password = Text_Password.Text.Trim(); data.ConfirmPassword = Text_ConfirmPassword.Text.Trim(); data.Country = ddlCountry.SelectedItem.ToString(); data.State = Text_state.Text.Trim(); data.City = Text_City.Text.Trim(); data.Dob = DateTime.Parse(Dob.Value); data.PhoneNumber = Text_PhoneNumber.Text.Trim(); data.MobileNumber = Text_MobileNumber.Text.Trim(); data.Currentlocation = Text_Currentlocation.Text.Trim(); data.PreferedJobLocations = Text_Location.Text.Trim(); data.JobCategory = ddljobcategory.SelectedItem.ToString(); data.KeySkills = Text_KeySkills.Text.Trim(); data.HighestQualificationheld = ddlhqh.SelectedItem.ToString(); data.SpecialisationMajor = ddlspecialisation.SelectedItem.ToString(); data.Institute = ddlinstitute.SelectedItem.ToString(); data.YearPassedOut = ddlyrpassedout.SelectedItem.ToString(); try { int res = data.insertreg(); if (res > 0) { Page.RegisterStartupScript("SS", "<script> alert('Completed Successfully');</script>"); } else { lblmessage.Text = "registration failed"; } } catch { } i have used 3 tier architecture the code in the dal layer for registration page static SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ToString()); internal static int insertreg(bal bal) { //throw new NotImplementedException(); con.Close(); con.Open(); SqlCommand cmd = new SqlCommand("sp_reg", con); cmd.CommandType = CommandType.StoredPr
-
we completed the registration page in our project and whatever the details we have given in that registration page they are also going to update in the backend also. but whatever the username and password we have given in the registration page is not accepted by the login page.while giving the username and password it is showing the error like below object reference is not set to an instance of an object code i have written for registration page bal data = new bal(); data.FirstName = Text_FirstName.Text.Trim(); data.LastName = Text_LastName.Text.Trim(); data.Gender = Text_Gender.Text.Trim(); data.EmailId = Text_EmailId.Text.Trim(); data.UserName = Text_UserName.Text.Trim(); data.Password = Text_Password.Text.Trim(); data.ConfirmPassword = Text_ConfirmPassword.Text.Trim(); data.Country = ddlCountry.SelectedItem.ToString(); data.State = Text_state.Text.Trim(); data.City = Text_City.Text.Trim(); data.Dob = DateTime.Parse(Dob.Value); data.PhoneNumber = Text_PhoneNumber.Text.Trim(); data.MobileNumber = Text_MobileNumber.Text.Trim(); data.Currentlocation = Text_Currentlocation.Text.Trim(); data.PreferedJobLocations = Text_Location.Text.Trim(); data.JobCategory = ddljobcategory.SelectedItem.ToString(); data.KeySkills = Text_KeySkills.Text.Trim(); data.HighestQualificationheld = ddlhqh.SelectedItem.ToString(); data.SpecialisationMajor = ddlspecialisation.SelectedItem.ToString(); data.Institute = ddlinstitute.SelectedItem.ToString(); data.YearPassedOut = ddlyrpassedout.SelectedItem.ToString(); try { int res = data.insertreg(); if (res > 0) { Page.RegisterStartupScript("SS", "<script> alert('Completed Successfully');</script>"); } else { lblmessage.Text = "registration failed"; } } catch { } i have used 3 tier architecture the code in the dal layer for registration page static SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ToString()); internal static int insertreg(bal bal) { //throw new NotImplementedException(); con.Close(); con.Open(); SqlCommand cmd = new SqlCommand("sp_reg", con); cmd.CommandType = CommandType.StoredPr
sritha wrote:
object reference is not set to an instance of an object
And what line is that error occurring?
sritha wrote:
catch { }
This is bad practice - Don't do it.
sritha wrote:
try { return ds; } catch { throw; } finally { cmd.Dispose(); con.Close(); }
WTF? Exactly what exception will
return ds
throw? Surely the try block should go around everything, not just the last line. You are not doing anything in the catch block other than rethrowing the exception. Remove the catch block it is not required. Your connection is stored elsewhere. .NET does connection pooling, don't keep connection objects around, create a new one each time.Man who stand on hill with mouth open wait long time for roast duck to drop in
-
we completed the registration page in our project and whatever the details we have given in that registration page they are also going to update in the backend also. but whatever the username and password we have given in the registration page is not accepted by the login page.while giving the username and password it is showing the error like below object reference is not set to an instance of an object code i have written for registration page bal data = new bal(); data.FirstName = Text_FirstName.Text.Trim(); data.LastName = Text_LastName.Text.Trim(); data.Gender = Text_Gender.Text.Trim(); data.EmailId = Text_EmailId.Text.Trim(); data.UserName = Text_UserName.Text.Trim(); data.Password = Text_Password.Text.Trim(); data.ConfirmPassword = Text_ConfirmPassword.Text.Trim(); data.Country = ddlCountry.SelectedItem.ToString(); data.State = Text_state.Text.Trim(); data.City = Text_City.Text.Trim(); data.Dob = DateTime.Parse(Dob.Value); data.PhoneNumber = Text_PhoneNumber.Text.Trim(); data.MobileNumber = Text_MobileNumber.Text.Trim(); data.Currentlocation = Text_Currentlocation.Text.Trim(); data.PreferedJobLocations = Text_Location.Text.Trim(); data.JobCategory = ddljobcategory.SelectedItem.ToString(); data.KeySkills = Text_KeySkills.Text.Trim(); data.HighestQualificationheld = ddlhqh.SelectedItem.ToString(); data.SpecialisationMajor = ddlspecialisation.SelectedItem.ToString(); data.Institute = ddlinstitute.SelectedItem.ToString(); data.YearPassedOut = ddlyrpassedout.SelectedItem.ToString(); try { int res = data.insertreg(); if (res > 0) { Page.RegisterStartupScript("SS", "<script> alert('Completed Successfully');</script>"); } else { lblmessage.Text = "registration failed"; } } catch { } i have used 3 tier architecture the code in the dal layer for registration page static SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ToString()); internal static int insertreg(bal bal) { //throw new NotImplementedException(); con.Close(); con.Open(); SqlCommand cmd = new SqlCommand("sp_reg", con); cmd.CommandType = CommandType.StoredPr
-
we completed the registration page in our project and whatever the details we have given in that registration page they are also going to update in the backend also. but whatever the username and password we have given in the registration page is not accepted by the login page.while giving the username and password it is showing the error like below object reference is not set to an instance of an object code i have written for registration page bal data = new bal(); data.FirstName = Text_FirstName.Text.Trim(); data.LastName = Text_LastName.Text.Trim(); data.Gender = Text_Gender.Text.Trim(); data.EmailId = Text_EmailId.Text.Trim(); data.UserName = Text_UserName.Text.Trim(); data.Password = Text_Password.Text.Trim(); data.ConfirmPassword = Text_ConfirmPassword.Text.Trim(); data.Country = ddlCountry.SelectedItem.ToString(); data.State = Text_state.Text.Trim(); data.City = Text_City.Text.Trim(); data.Dob = DateTime.Parse(Dob.Value); data.PhoneNumber = Text_PhoneNumber.Text.Trim(); data.MobileNumber = Text_MobileNumber.Text.Trim(); data.Currentlocation = Text_Currentlocation.Text.Trim(); data.PreferedJobLocations = Text_Location.Text.Trim(); data.JobCategory = ddljobcategory.SelectedItem.ToString(); data.KeySkills = Text_KeySkills.Text.Trim(); data.HighestQualificationheld = ddlhqh.SelectedItem.ToString(); data.SpecialisationMajor = ddlspecialisation.SelectedItem.ToString(); data.Institute = ddlinstitute.SelectedItem.ToString(); data.YearPassedOut = ddlyrpassedout.SelectedItem.ToString(); try { int res = data.insertreg(); if (res > 0) { Page.RegisterStartupScript("SS", "<script> alert('Completed Successfully');</script>"); } else { lblmessage.Text = "registration failed"; } } catch { } i have used 3 tier architecture the code in the dal layer for registration page static SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ToString()); internal static int insertreg(bal bal) { //throw new NotImplementedException(); con.Close(); con.Open(); SqlCommand cmd = new SqlCommand("sp_reg", con); cmd.CommandType = CommandType.StoredPr
sritha wrote:
object reference is not set to an instance of an object
Did you debug your code? Where are you getting the error ? Does that object initialize?
cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net