V
Vigneshwar Pilli via DotNetMonster.com
Hey,
Well, I have a Problem.
I have designed a table which has few fields which are being declared in
the database of type ....
char of length 10.
and other fields with varchar 50 and datetime too.
Well, the Problem is I am not able to display the CHAR type FIELDS in the
form when I am trying to pull them from the database and show it in the
form,
where as I am able to see the values for the fields declared in VARCHAR (50)
, to the appropriate controls( I mean to say to the textbox or the drop
down box they are binded to).
I need to show even these, char type variable values too in the form fields
but these are not being displayed,
I changed these fields too to Varchar and tried, the data being entered
into the records after I changed to Varchar are being displayed but not the
data of the records which was stored as CHAR (10).
Well I need some kind of solution to fix this problem.
here is the code how I am doing that........
hey.. I tried this TRIM finally but even then the fields were not being
displayed.
string sql="Select * From Student_SDS Where SSN='" + Session["SSN"] + "'";
dbCommand1 = new SqlCommand (sql, dbConnection1);
dbConnection1.Open(); SqlDataReader dr = dbCommand1.ExecuteReader();
dr.Read();
THESE FIELDS ARE BEING DISPLAYED the datatypes of these are..VARCHAR(50)
LName.Text = Convert.ToString(dr["LName"]);
FName.Text= Convert.ToString(dr["FName"]);
MName.Text= Convert.ToString(dr["MName"]);
Lstate.SelectedIndex=Lstate.Items.IndexOf(Lstate.Items.FindByValue(dr
["Lstate"].ToString().Trim()));
SClassification.SelectedIndex=SClassification.Items.IndexOf
(SClassification.Items.FindByValue(dr["SClassification"].ToString()));
These Fields are not being Displayed, the datatype of these fields is CHAR
(10).
SchoolState.SelectedIndex=SchoolState.Items.IndexOf
(SchoolState.Items.FindByValue(dr["SchoolState"].ToString()));
ProgType.SelectedIndex=ProgType.Items.IndexOf(ProgType.Items.FindByValue(dr
["ProgType"].ToString().Trim()));
StayType.SelectedIndex=StayType.Items.IndexOf(StayType.Items.FindByValue(dr
["StayType"].ToString().Trim()));
EnrollmentType.SelectedIndex=EnrollmentType.Items.IndexOf
(EnrollmentType.Items.FindByValue(dr["EnrollmentType"].ToString().Trim()));
EnrollmentTerm.SelectedIndex=EnrollmentTerm.Items.IndexOf
(EnrollmentTerm.Items.FindByValue(dr["EnrollmentTerm"].ToString()));
SDSApplied.SelectedIndex=SDSApplied.Items.IndexOf
(SDSApplied.Items.FindByValue(dr["SDSApplied"].ToString().TrimEnd()));
AwardWilling.SelectedIndex=AwardWilling.Items.IndexOf
(AwardWilling.Items.FindByValue(dr["AwardWilling"].ToString().Trim()));
USCitizen.SelectedIndex=USCitizen.Items.IndexOf(USCitizen.Items.FindByValue
(dr["USCitizen"].ToString().TrimStart()));
ParentGrad.SelectedIndex=ParentGrad.Items.IndexOf
dr.Close();
dbConnection1.Close();
System.Data.SqlClient.SqlConnection dbConnection2 = new
System.Data.SqlClient.SqlConnection(connectionString1);
System.Data.SqlClient.SqlCommand dbCommand2 = new
System.Data.SqlClient.SqlCommand();
dbConnection2.Open();
SqlDataReader dr1 = dbCommand2.ExecuteReader();
dr1.Read();
dr1.Close();
dbConnection2.Close();
well, I donot know whats the problem and,.. what thing I can try to show
these records, already a lot of data is being entered with the fields with
CHAR datatype, I can change the table structure and can see the records
being entered there onwards, but I have to show the fields of CHAR type
being declared tooooooo.
Please provide me some solution.
Thanks and Regards,
Viggi.
Well, I have a Problem.
I have designed a table which has few fields which are being declared in
the database of type ....
char of length 10.
and other fields with varchar 50 and datetime too.
Well, the Problem is I am not able to display the CHAR type FIELDS in the
form when I am trying to pull them from the database and show it in the
form,
where as I am able to see the values for the fields declared in VARCHAR (50)
, to the appropriate controls( I mean to say to the textbox or the drop
down box they are binded to).
I need to show even these, char type variable values too in the form fields
but these are not being displayed,
I changed these fields too to Varchar and tried, the data being entered
into the records after I changed to Varchar are being displayed but not the
data of the records which was stored as CHAR (10).
Well I need some kind of solution to fix this problem.
here is the code how I am doing that........
hey.. I tried this TRIM finally but even then the fields were not being
displayed.
string sql="Select * From Student_SDS Where SSN='" + Session["SSN"] + "'";
dbCommand1 = new SqlCommand (sql, dbConnection1);
dbConnection1.Open(); SqlDataReader dr = dbCommand1.ExecuteReader();
dr.Read();
THESE FIELDS ARE BEING DISPLAYED the datatypes of these are..VARCHAR(50)
LName.Text = Convert.ToString(dr["LName"]);
FName.Text= Convert.ToString(dr["FName"]);
MName.Text= Convert.ToString(dr["MName"]);
Lstate.SelectedIndex=Lstate.Items.IndexOf(Lstate.Items.FindByValue(dr
["Lstate"].ToString().Trim()));
SClassification.SelectedIndex=SClassification.Items.IndexOf
(SClassification.Items.FindByValue(dr["SClassification"].ToString()));
These Fields are not being Displayed, the datatype of these fields is CHAR
(10).
SchoolState.SelectedIndex=SchoolState.Items.IndexOf
(SchoolState.Items.FindByValue(dr["SchoolState"].ToString()));
ProgType.SelectedIndex=ProgType.Items.IndexOf(ProgType.Items.FindByValue(dr
["ProgType"].ToString().Trim()));
StayType.SelectedIndex=StayType.Items.IndexOf(StayType.Items.FindByValue(dr
["StayType"].ToString().Trim()));
EnrollmentType.SelectedIndex=EnrollmentType.Items.IndexOf
(EnrollmentType.Items.FindByValue(dr["EnrollmentType"].ToString().Trim()));
EnrollmentTerm.SelectedIndex=EnrollmentTerm.Items.IndexOf
(EnrollmentTerm.Items.FindByValue(dr["EnrollmentTerm"].ToString()));
SDSApplied.SelectedIndex=SDSApplied.Items.IndexOf
(SDSApplied.Items.FindByValue(dr["SDSApplied"].ToString().TrimEnd()));
AwardWilling.SelectedIndex=AwardWilling.Items.IndexOf
(AwardWilling.Items.FindByValue(dr["AwardWilling"].ToString().Trim()));
USCitizen.SelectedIndex=USCitizen.Items.IndexOf(USCitizen.Items.FindByValue
(dr["USCitizen"].ToString().TrimStart()));
ParentGrad.SelectedIndex=ParentGrad.Items.IndexOf
dr.Close();
dbConnection1.Close();
System.Data.SqlClient.SqlConnection dbConnection2 = new
System.Data.SqlClient.SqlConnection(connectionString1);
System.Data.SqlClient.SqlCommand dbCommand2 = new
System.Data.SqlClient.SqlCommand();
dbConnection2.Open();
SqlDataReader dr1 = dbCommand2.ExecuteReader();
dr1.Read();
dr1.Close();
dbConnection2.Close();
well, I donot know whats the problem and,.. what thing I can try to show
these records, already a lot of data is being entered with the fields with
CHAR datatype, I can change the table structure and can see the records
being entered there onwards, but I have to show the fields of CHAR type
being declared tooooooo.
Please provide me some solution.
Thanks and Regards,
Viggi.