Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Data Type Conversion Problem
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01369981
Message ID:
01369987
Vues:
9
>I'm working on a project that imports an Excel file into a database. It's 99% done, and now I have run into a problem. This is a bit long, but I could use some help.
>
>I have a class in the project which represents column info:
>
>
>public class ExcelExportColumnInfo
>{
>    private ColumnType _Type;
>    private string _DBColumnName = "";
>    private string _ExcelColumnName = "";
>
>    public enum ColumnType
>    {
>        String,
>        Int32
>    }
>
>    public ColumnType Type
>    {
>        get { return _Type; }
>        set { _Type = value; }
>    }
>
>    public string ExcelColumnName
>    {
>        get { return _ExcelColumnName; }
>        set { _ExcelColumnName = value; }
>    }
>
>    public string DBColumnName
>    {
>        get { return _DBColumnName; }
>        set { _DBColumnName = value; }
>    }
>}
>
>
>I then create instances of the column info class for each column in the Excel file that is to be imported into the database:
>
>// Collection to hold the column information
>ArrayList Columns = new ArrayList();
>
>// One object for each column
>ExcelExportColumnInfo Col1 = new ExcelExportColumnInfo();
>Col1.DBColumnName = "Customer";
>Col1.ExcelColumnName = "Conctrac # -- Customer";
>Col1.Type = ExcelExportColumnInfo.ColumnType.String;
>Columns.Add(Col1);
>
>ExcelExportColumnInfo Col2 = new ExcelExportColumnInfo();
>Col2.DBColumnName = "Quantity";
>Col2.ExcelColumnName = "Quantity";
>Col1.Type = ExcelExportColumnInfo.ColumnType.Int32;
>Columns.Add(Col2);
>
>ExcelExportColumnInfo Col3 = new ExcelExportColumnInfo();
>Col3.DBColumnName = "PartNumber";
>Col3.ExcelColumnName = "Part Number";
>Col1.Type = ExcelExportColumnInfo.ColumnType.String;
>Columns.Add(Col3);
>
>ExcelExportColumnInfo Col4 = new ExcelExportColumnInfo();
>Col4.DBColumnName = "Location";
>Col4.ExcelColumnName = "Ship To";
>Col1.Type = ExcelExportColumnInfo.ColumnType.String;
>Columns.Add(Col4);
>
>// Call the method to export the sheet to the database
>Excel.ExportSheetToDB(ExpInfo, Columns);
>
>
>
>The second column's Type property should be ExcelExportColumnInfo.ColumnType.Int32.
>
>Please see the following pic: http://marois.freewebspace.com/pic1.JPG. Notice that somehow it is being stored in the property as a string.
>
>Anyone know what's wrong here?

Can't view the link.......
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform