wonder_laptop -3 Junior Poster in Training

Im Writing a c# Code that Takes an Excel Sheet ,creates the Corresponding SQl table and Dumps the data in a new table in SQL.

Now My problem is:

In the " create table" command , i have to specify the DATATYPE for the column !i.e.

CREATE TABLE "table_name"
("column 1" "data_type_for_column_1",
"column 2" "data_type_for_column_2",
... )

So i wrote the following code that saves the Excel Column names in the strColumnNameArray (of type String)
and their corresponding Data Types in the DataTypeArray (of type Type)

foreach (DataRow row in schemaTable.Rows)
                strColumnNameArray[i] = ((string)row["ColumnName"]);
                DataTypeArray[i] = (Type)row["DataType"];

Then i want to Convert the Excel Datatypes in the DataTypeArray to the corresponding SQL datatypes, so i wrote the following that Saves the SQL Types in SqlTypeArray (of type SqlDbType)

c = 0;
             foreach (Type t in DataTypeArray)
                 SqlTypeArray[c] = GetDbType(DataTypeArray[c]);

The Excel Columns are all of type Currency , and according to that site: http://msdn.microsoft.com/en-us/library/ms712640(VS.85), a Currency Type should be converted to a SQL_numeric Type, however, all my columns are converted to NVarChar Sql type !! any idea where im going wrong :S:S please help !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.