473,320 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problem in displaying few fields......... using DATA READER.

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.I tems.FindByValue(dr
["Lstate"].ToString().Trim()));
SClassification.SelectedIndex=SClassification.Item s.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.IndexO f
(SchoolState.Items.FindByValue(dr["SchoolState"].ToString()));
ProgType.SelectedIndex=ProgType.Items.IndexOf(Prog Type.Items.FindByValue(dr
["ProgType"].ToString().Trim()));
StayType.SelectedIndex=StayType.Items.IndexOf(Stay Type.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.Inde xOf
(AwardWilling.Items.FindByValue(dr["AwardWilling"].ToString().Trim()));
USCitizen.SelectedIndex=USCitizen.Items.IndexOf(US Citizen.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(connectionStri ng1);
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.

--
Message posted via http://www.dotnetmonster.com
Nov 19 '05 #1
4 1841

"Vigneshwar Pilli via DotNetMonster.com" <fo***@nospam.DotNetMonster.com>
wrote in message news:a3******************************@DotNetMonste r.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.I tems.FindByValue(dr
["Lstate"].ToString().Trim()));
SClassification.SelectedIndex=SClassification.Item s.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.IndexO f
(SchoolState.Items.FindByValue(dr["SchoolState"].ToString()));
ProgType.SelectedIndex=ProgType.Items.IndexOf(Prog Type.Items.FindByValue(dr ["ProgType"].ToString().Trim()));
StayType.SelectedIndex=StayType.Items.IndexOf(Stay Type.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.Inde xOf
(AwardWilling.Items.FindByValue(dr["AwardWilling"].ToString().Trim()));
USCitizen.SelectedIndex=USCitizen.Items.IndexOf(US Citizen.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(connectionStri ng1);
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.

--
Message posted via http://www.dotnetmonster.com

Nov 19 '05 #2
It's hard to tell what's the exact problem without looking at the error
code(if any). As an alternative, you can convert the char columns to varchar
in the sql and it should work.

string sql="Select * From Student_SDS Where SSN='" + Session["SSN"] + "'";
to something like..
string sql="Select *, convert(varchar,char_field) converted_field From
Student_SDS Where SSN='" + Session["SSN"] + "'";

Thanks,
Prodip
www.aspnet4you.com

"Vigneshwar Pilli via DotNetMonster.com" <fo***@nospam.DotNetMonster.com>
wrote in message news:a3******************************@DotNetMonste r.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.I tems.FindByValue(dr
["Lstate"].ToString().Trim()));
SClassification.SelectedIndex=SClassification.Item s.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.IndexO f
(SchoolState.Items.FindByValue(dr["SchoolState"].ToString()));
ProgType.SelectedIndex=ProgType.Items.IndexOf(Prog Type.Items.FindByValue(dr ["ProgType"].ToString().Trim()));
StayType.SelectedIndex=StayType.Items.IndexOf(Stay Type.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.Inde xOf
(AwardWilling.Items.FindByValue(dr["AwardWilling"].ToString().Trim()));
USCitizen.SelectedIndex=USCitizen.Items.IndexOf(US Citizen.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(connectionStri ng1);
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.

--
Message posted via http://www.dotnetmonster.com

Nov 19 '05 #3
Hey, Dude...
Well, I Didnt get the query solution u have suggested,

Can U make it clear with an example say,

the fields which are of char data type be.... Fname, Lname

can u put them in a proper query you were suggesting me to do,

please, I tried but was getting some error in the format, so please just
get me the proper QUERY.

THANSK AND regards,

viggi

--
Message posted via http://www.dotnetmonster.com
Nov 19 '05 #4
Here is an example-
declare @FName char(10)
select @FName='Vigneshwar[this portion will be trimed]'
select convert(varchar,@FName) FName

Thanks,

Prodip

"Vigneshwar Pilli via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in
message news:00******************************@DotNetMonste r.com...
Hey, Dude...
Well, I Didnt get the query solution u have suggested,

Can U make it clear with an example say,

the fields which are of char data type be.... Fname, Lname

can u put them in a proper query you were suggesting me to do,

please, I tried but was getting some error in the format, so please just
get me the proper QUERY.

THANSK AND regards,

viggi

--
Message posted via http://www.dotnetmonster.com

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: kevininstructor | last post by:
I found code on the web which takes data from an MS-Access table (my test table has three rows by five fields) copies it to the Clipboard then into a range within MS-Excel. Data is stored in a...
6
by: Stephen Cook | last post by:
Having worked through the problems around enabling the document function using an XmlUrlResolver I started work on building a useful class to hide the intricacies. Trying to generalise the process...
0
by: Michael Probst | last post by:
Hi all, I am new to .NET and the way XML data is handled in .NET I wrote a small application with .NET forms in C++ The application reads data from an XML file to fill-in the fields of the...
1
by: Joe Bloggs | last post by:
I am trying display the contents of a table in a web page, select certain rows from that table and then display the fields that I have selected (now table columns) as text in a Label object....
2
by: Mad Scientist Jr | last post by:
i'm trying to read a file byte by byte (and later alter the data and write it to a 2nd file byte by byte) and running into a problem where it seems to keep reading the same byte over and over again...
1
by: Christopher Brandsdal | last post by:
Hi! I have problems displaying a XML-file the way i want on my website. This is the link to the file I have to display(ps: the file is on a remote server, so I have to the file via http or...
2
by: Thelonious Monk | last post by:
I have a problem where some data is being eliminated. The problem is that the data contains signed numeric fields (the low-order byte of a negative number uses the first 4 bits as a sign and...
4
by: Debbiedo | last post by:
I searched the groups and tried several approaches but still cannot find a solution. I have a table that has several hundred fields that may or may not need to be displayed in a report,...
2
by: sweatha | last post by:
Hi friends This is sweatha, fresher MCA 2007 batch. Right now I am working in asp.net platform. My dillema is that I have created a registration form with the fields as username & password. And if...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.