0

I am trying to fetch some records from IBM AS400 db2 database.

here i am selecting records from AS400 using select query where there are multiple columns having different data type. now problem arises here when i try to read specific 2 columns where the data type is 'O' - DBCS which contains the simple Name and short name of persons.

                   foreach (var record in source.Read(recordsObject, i))
                        {
                            for (int j = 0; j < n; j++)
                            {
                                // mycode to show record
                            }
                        }

Its a simple select query without any join, nothing.

select col1,col2, col3, col4, col5 from as400Table

I have tried with casting it at query itself as varchar with different sizes, tries various ways, but it shows me the error like this --

"The data value could not be converted for reasons other than sign mismatch or data overflow. For example, the data was corrupted in the data store but the row was still retrievable."

I have also tried changing the driver to IBM i Access for windows 7.1 but there also it gives me error like -- Conversion Error with message code - 6101.

other then this 2 columns, remaining columns are easily retrievable.

is there any specific issue while reading this type of data using C# ?

here i am using IBM iAccess Client Solution to connect with AS400.

Please suggest any solutions for this, i have searched at internet and it

Any suggestions is appreciated. Thanks.

Edit:

I am retrieving the data like this as the alternate to above mentioned code.

using (iDB2Connection connection1 = new iDB2Connection(connectionString))
{
 connection1.Open();

string sql = @"select col1,col2, col3, col4, col5 from as400Table";
    using (iDB2Command command = new iDB2Command(sql, connection1))
                    {
                        using (iDB2DataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {

                            }
                        }
                        }
 connection1.close();
}
4
  • Could you post how you're retrieving your values? Commented Jun 4, 2023 at 0:14
  • 6101 - the requested code page conversion is not supported. Please edit your question to specify the codepage of the database/table/column, AND the codepage of your application (i.e. the regional settings on your Microsoft-Windows workstation where you run your c# code) Commented Jun 4, 2023 at 20:54
  • @silkfire i have updated the post, you can check that Commented Jun 5, 2023 at 3:52
  • @AshwinBehera See whether this answer can help you (based on David's answer referring to translating CCSID-encoded data): stackoverflow.com/a/51756239/633098 Commented Dec 31, 2024 at 23:17

1 Answer 1

0

It's been a long time since I worked on DBCS tables, but I think you may have to set your connection to use a specific CCSID so the database can trans-code between the client app and the table.

I don't know C#, so I really can't tell you how this would be done.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.