ASP.NET C# ODBC Select query is returning truncated result string

Hello all,

I am trying to populate a drop down list with a database query in an ASP.NET project. My problem is that the result values from the query are being truncated at 15 characters, and I don't know why this would be.

I am using System.Data.ODBC.

I am creating my database connection using OdbcConnection("SYSTEM_DSN");
OdbcConnection cxconn = new OdbcConnection("DSN=SYSTEMDSN");

My query is in a string:
//build the select statement to get items to populate session drop-down
string ProgramQuery = "SELECT major_table.txt_adm from major_table where major_table.dept = 'EXCL' ";
ProgramQuery += "and major_table.web_display = 'Y' and major_table.inactive_date is NULL;";


And this is how I execute the query and populate my drop-down:
 OdbcCommand cxcommand = cxconn.CreateCommand();
            cxcommand.CommandText = ProgramQuery;

            try
            {
                OdbcDataReader dbreader = cxcommand.ExecuteReader();
                // rest of the code to process the result set
                int fCount = dbreader.FieldCount;
                //Response.Write(dbreader.FieldCount);
                while (dbreader.Read())
                {
                    for (int i = 0; i < fCount; i++)
                    {
                        Response.Write(" " + dbreader.GetValue(i));
                        ddlProg.Items.Add(dbreader.GetString(i));

                    }

                }

                //close the dbreader
                dbreader.Close();


                //bind the data on ddlSess and set the selected value by default to be the first one.
                ddlProg.DataBind();
                ddlProg.SelectedIndex = 0;

                cxcommand.Dispose();
                cxconn.Close();

The resulting values in the drop down list are truncated at 15 characters. So, "Business Administration" becomes "Business Admini". I am unable to figure out why this is the case. My database is an INFORMIX database and I have the system DSN created using the INFORMIX 3.80 32 BIT driver.

Any help would be really appreciated. Thanks for looking into this.

Regards.
gcampbell1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Todd GerbertIT ConsultantCommented:
I would guess simply that the drop down list isn't wide enough; the values are not being truncated, but all the characters cannot be shown. Is the width of the drop-down list explicity specified in the <asp:DropDownList> tag?
0
gcampbell1Author Commented:
Thanks for your reply.

No, the width is  not the issue. I tried to expand the dropdownlist width, and the values were still truncated. I don't think this is a problem with the drop down list because the "Response.Write" line in the for loop prints out the truncated value as well.

I am not sure if it is an OdbcDataReader issue or an informix driver issue, but those two would be my guesses as problem areas. I just don't know where to even start looking.
0
Todd GerbertIT ConsultantCommented:
I don't think I see anything in your code that would cause that behavior - is the column in the Informix database defined as 15 characters wide (the MS SQL equivelant of char(15))?
0
gcampbell1Author Commented:
Thanks, again, for the reply. The database was not the problem either (since the value is stored properly on the database end).

I realized the problem was the INFORMIX 3.80 driver for the System DSN. I tried using the 3.34 driver and the string is no longer getting truncated.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Databases

From novice to tech pro — start learning today.