Click here to Skip to main content
16,021,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
plz help me for solving my problem.
when i insert the record in database form the code page. then error occur at the place of errorcode in BAL file.
ERROR- Object cannot be cast from dbnull to other types.
but i am fillup the all textbox values.


Thanks in advance.....
Posted
Comments
Prasad_Kulkarni 27-Apr-12 8:01am    
can u post your code here?
dA.d 27-Apr-12 9:14am    
protected void btnUpdate_Click(object sender, EventArgs e)
{
BAL.ManageFacultyStaff ObjBalMngFacultyStaff = new BAL.ManageFacultyStaff();
ENTITY.ManageFacultyStaff ObjEntityMngFacultyStaff = new ENTITY.ManageFacultyStaff();
System.Data.SqlTypes.SqlDateTime getDateTime;
getDateTime = SqlDateTime.Null;

ObjEntityMngFacultyStaff.UserId = Convert.ToInt32(lblUserId.Text);
ObjEntityMngFacultyStaff.LoginEmail = txtEmail.Text;
ObjEntityMngFacultyStaff.Password = txtPassword.Text;
ObjEntityMngFacultyStaff.FName = txtFName.Text;
ObjEntityMngFacultyStaff.MName = txtMName.Text;
ObjEntityMngFacultyStaff.LName = txtLName.Text;
if (rblGender.SelectedValue == "0")
{
ObjEntityMngFacultyStaff.Gender = false;
}
else
{
ObjEntityMngFacultyStaff.Gender = true;
}
if (txtBirthDate.Text != "")
{
ObjEntityMngFacultyStaff.Birthdate = DateTime.Parse(txtBirthDate.Text, System.Globalization.CultureInfo.CreateSpecificCulture("en-AU").DateTimeFormat);
}
else
{
ObjEntityMngFacultyStaff.Birthdate = getDateTime;
}
ObjEntityMngFacultyStaff.AddressLine1 = txtAddress1.Text;
ObjEntityMngFacultyStaff.AddressLine2 = txtAddress2.Text;
bbirajdar 27-Apr-12 10:17am    
Which line gives you the error?
S@53K^S 27-Apr-12 10:50am    
Seems like you have posted wrong code here as you are assigning values to the entity object.So there is now way that this code could have given you error.And why are you instantiating getDateTime to dbnull?? if you are not using it anywhere else.

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900