开发者

How to set an array value using sp_OASetProperty

I have a stored procedure that manipulates some data in an excel spreadsheet. I am importing data by creating a QueryTable object. I would like to set TextFileColu开发者_开发知识库mnDataTypes property for the object but I can't figure out how to pass in an array to the sp_OASetProperty routine.

This is what my code looks like but obviously it doesn't work:

EXECUTE @rc = master..sp_OASetProperty @xlQueryTable, 'TextFileColumnDataTypes', 'Array(xlTextFormat, xlTextFormat, xlGeneralFormat)'

Is there any way to do this?


Where do the values for xlTextFormat and xlGeneralFormat come from? Is it possible this should be one of the following:

DECLARE @command VARCHAR(255);

SET @command = 'Array(' + @xlTextFormat + ', ' + @xlTextFormat + ', ' + @xlGeneralFormat + ')';
-- or
SET @command = 'Array("' + @xlTextFormat + '", "' + @xlTextFormat + '", "' + @xlGeneralFormat + '")';
-- or
SET @command = 'Array("xlTextFormat", "xlTextFormat", "xlGeneralFormat")';

EXEC @rc = master..sp_OASetProperty @xlQueryTable, 'TextFileColumnDataTypes', @command;

Otherwise maybe you should ditch sp_OA and use CLR.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜