Um. Do we have more information online about this?

You see, since I use the JEXEServer.SetB interface exclusively, I have
been forced to convert my data to string. 

As an example, here is my C# code which takes a .NET DataTable and
creates a CSV string delimited by (16{a.) and (17{a.) for columns and
rows using the StringBuilder class. As you can imagine, when converting
49,000 rows of data ... there is a very noticeable delay before the data
read from MS-SQL is actually given to the J Session.

Here is the code snippet from my project:
       /// <summary>
        /// Converts a data table to an script that can be imported to
EOE
        /// </summary>
        public static string dataTableToEOE(DataTable sourceTable)
        {
            // Variable declaration
            StringBuilder fields, data;
            data = new StringBuilder("");
            fields = new StringBuilder("");
            string oType;
            //fields = data = "";

            // Lets create the fieldlist first
            foreach (DataColumn myDataColumn in sourceTable.Columns)
            {
                // Save the field name with a TAB 
                fields.Append(myDataColumn.ColumnName).Append("\t");
                oType = myDataColumn.DataType.ToString();
                switch (oType)
                {
                    case "System.Byte":
                    case "System.Decimal":
                    case "System.Double":
                    case "System.Int16":
                    case "System.Int32":
                    case "System.Int64":
                    case "System.SByte":
                    case "System.UInt16":
                    case "System.UInt32":
                    case "System.UInt64":
                        fields.Append("numeric");
                        break;
                    case "System.DateTime":
                    case "System.TimeSpan":
                        fields.Append("datetime");
                        break;
                    case "System.Boolean":
                        fields.Append("boolean");
                        break;
                    default:
                        // Treat everyting else as string
                        fields.Append("text");
                        break;
                }
                // Now add CRLF
                fields.Append("\n");
            }

            // Now retrieve all row data
            foreach (DataRow myDataRow in sourceTable.Rows)
            {
                // Get the string value for each column
                for (int i = 0; i < myDataRow.ItemArray.Length; i++)
                {
                    if (myDataRow[i] == DBNull.Value)
                    {
                        data.Append(CHR16);
                    }
                    else
                    {
                        data.Append(myDataRow[i]).Append(CHR16);
                    }
                }

                // Add the row delimiter
                data.Append(CHR17);
            }

            // Return the data
            return (fields.ToString() + CHR18.ToString() +
data.ToString());
        }

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to