Cari Blog Ini

20 Juni 2012

OLE DB provider 'Microsoft.Jet.OLEDB.4.0' Supplied Invalid Metadata For Column

Error Messages : 

OLE DB provider 'Microsoft.Jet.OLEDB.4.0' supplied invalid metadata for column 'KdCabang'.
The data type is not supported.
OLE DB error trace
[Non-interface error:  Column 'KdCabang' (ordinal 1) of object
'SELECT KdCabang, Cabang FROM [Sheet1$]'
reported an unsupported value for DBTYPE of 0].



* * * * *



Case:

This query use for export data from SQL to existing file excel
* When run query in point A, there is an error messages like in point B


* Point A
------------------------------------------------------------------
-----code:start
------------------------------------------------------------------
INSERT INTO OPENROWSET
    ('Microsoft.Jet.OLEDB.4.0',
    'Excel 8.0;
    Database=D:\Testing.xls;',
    'SELECT KdCabang, Cabang FROM [Sheet1$]')

    SELECT KdCabang, Cabang FROM Cabang
GO
------------------------------------------------------------------
-----code:end
------------------------------------------------------------------


* Point B : Error Messages
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' supplied invalid metadata for column 'KdCabang'.
The data type is not supported.
OLE DB error trace
[Non-interface error:  Column 'KdCabang' (ordinal 1) of object
'SELECT KdCabang, Cabang FROM [Sheet1$]'
reported an unsupported value for DBTYPE of 0].


It happened because:
* The header column "KdCabang", column "Cabang" in existing file excel,
name "Testing.xls", sheet name "Sheet1",
there is no available.


Solution:
* Must check in existing file excel, name "Testing.xls" , sheet name "Sheet1", at Drive D:\,
there is must a header column "KdCabang", column "Cabang".

* If there is no header column  "KdCabang", column "Cabang",
you must create/add them first, then run the query in Point A again.