MIDRANGE dot COM Mailing List Archive



Home » SYSTEMIDOTNET » May 2008

Re: DataGridView field error - SOLUTION FOUND



fixed

For all 3 of you that may have been following this thread, I have
finally discovered what my issue is. I'll explain it here for the
archives:

JD Edwards, the database I've been attempting to pull from, ships their
files with CCSID 65535 on several of the fields. They started doing
this after V3R1 due to foreign language difficulties. Needless to say,
pulling data from the i5 with a CCSID of 65535 brings over invalid data
- similar to a decimal data error in RPG.

The solution is create an SQL View, preferably in a separate library,
and use the CAST() function on the fields to change the CCSID back to
37. Once I did this, and changed my VB.NET code to pull from the new
View instead of the base JDE file, the program began working perfectly.

Sincerely
Bob Cagle
IT Manager
Lynk, Inc.



-----Original Message-----
From: systemidotnet-bounces@xxxxxxxxxxxx
[mailto:systemidotnet-bounces@xxxxxxxxxxxx] On Behalf Of Bob Cagle
Sent: Monday, May 05, 2008 4:10 PM
To: .net use with the System i
Subject: Re: [SystemiDotNet] DataGridView field error

UPDATE: I now have both my client and the i5 running on the same release
level of V5R3. I am just attempting to use the IBM DB2 .Net provider to
load a DataGridView. I keep getting this error:

The following exception occurred in the DataGridView:

System.ArugumentException: Parameter is not valid. at
... at ... at ... at
System.Windows.Forms.DataGridViewCell.GetFormattedValue(Object value,
Int32 rowIndex, DataGridViewCellStyle& cellStyle, TypeConverter
valueTypeConverter, TypeConverter formattedValueTypeConverter,
DataGridViewDataErrorContexts context)



Here's a snippet of my code:

Private Sub Do_Query()
Dim oDS As New DataSet()

oDS = CreateDataSet("Select * from DATALIB.F41021", oDS,
"Input")

DataGridView1.DataSource = oDS
DataGridView1.DataMember = "Input"
End Sub

Private Function CreateDataSet(ByVal strSQL As String, ByVal
oDataSet As DataSet, ByVal strTableName As String) As DataSet
Dim connDB As New iDB2Connection()
Dim cmdDB As New iDB2Command()
Dim oDataAdapter As New iDB2DataAdapter()

connDB.ConnectionString = "DataSource=1.1.1.1"
connDB.Open()
cmdDB.Connection = connDB
oDataAdapter.SelectCommand = cmdDB
cmdDB.CommandText = strSQL
oDataAdapter.Fill(oDataSet, strTableName)

oDataAdapter = Nothing
cmdDB = Nothing
connDB.Close()

Return oDataSet
End Function


This seems pretty simple and straightforward. I'm sure several others
are doing the exact same thing. Has anyone else seen this error?

Thanks
Bob Cagle



-----Original Message-----
From: systemidotnet-bounces@xxxxxxxxxxxx
[mailto:systemidotnet-bounces@xxxxxxxxxxxx] On Behalf Of Bob Cagle
Sent: Friday, May 02, 2008 3:08 PM
To: .net use with the System i
Subject: Re: [SystemiDotNet] DataGridView field error

I tried changing my Select statement to include CHAR() around the field
in question, but that didn't work, or I got the syntax wrong, because
then I got the Object Reference Not Set error when I attempted to
reference the field - so the field was never defined.

I have also since discovered that the problem is not limited to this one
field. I have tested several different files, and I seem to get the
same error on most alpha fields, but not all.

I am thinking now that it is an incompatibility between my client and
the i5 - I am running the V5R4 version of iSeries Access, and thus the
DB2 .Net data provider, but my i5 is still at V5R3 for the time being.

I'll do my best to get the upgrade scheduled and completed so that I can
test that theory.

-----Original Message-----
From: systemidotnet-bounces@xxxxxxxxxxxx
[mailto:systemidotnet-bounces@xxxxxxxxxxxx] On Behalf Of Elvis Budimlic
Sent: Thursday, May 01, 2008 11:46 AM
To: '.net use with the System i'
Subject: Re: [SystemiDotNet] DataGridView field error

What you deduced makes sense. One thing that's not clear is if you've
hardcoded the columns being returned or just let the DataGridView
dynamically create them (usual case). If you've hardcoded the columns,
you
ought to be able to change them then.

If it is dynamic and it's the issue with the DataGridView
misinterpreting
the data type (shouldn't do that, but...), perhaps you can change your
SQL
SELECT statement to explicitly cast that column to character (i.e.
CHAR(myColumn)).

I wish I knew more about .net to give you some .net type options but I'm
still learning as well.

HTH, Elvis

Celebrating 11-Years of SQL Performance Excellence on IBM i, i5/OS and
OS/400
www.centerfieldtechnology.com

-----Original Message-----
Subject: [SystemiDotNet] DataGridView field error

I have a small test app that I've been playing with, learning how to
connect and pull data from my i5. Good news is I got it working
perfectly. Bad news is I changed the input file and now it's not
working.

The file that I have changed to is a JD Edwards file that has the
Business Unit field in it. This is a very common field in JDE, and a
little strange. It's a 12 digit character field, but almost always has
a right-justified numeric value in it.

I am including this field in my grid, along with the Item number and
Quantity on hand. When the grid loads, I see a red 'X' for the Business
Unit and I get the following error:

System.Windows.Forms.DataGridViewCell.GetFormattedValue(Object value,
Int32 rowIndex, DataGridViewCellStyle& cellStyle, TypeConverter
valueTypeConverter, TypeConverter formattedValueTypeConverter,
DataGridViewDataErrorContexts context)

I have no idea what this means, but I assume it means that VB is
assuming that this field is numeric, but then crashing when it finds
there is non-numeric data in the field (blanks). The other two fields
show up fine.

How do I resolve this error? Is there a specific property I need to set
on the column to force a character data type?

Thanks

Bob Cagle





Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot COM and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available here. If you have questions about this, please contact