开发者

Insert table data from .NET dataset into SAS data file via OLEDB

I have C# .NET code with a DataSet (System.Data.DataSet) containing one table of data, and I'm trying to create a new SAS data table on a SAS server and then push the data into it using C#.

Right now, I can create the new table on the SAS server, but I'm not sure how to transfer the data. I tried using this insert command (exportData is the DataSet):

"INSERT INTO SASUSER." + SAStableName + " SELECT * FROM " + exportData.Tables[0].TableName

But it thinks that the exportData table name is supposed to be a SAS library name. All I get when searching the web is examples that only take data out of SAS, which is easy with a TableDirect command type and the OLEDB fill method. It seems to be not so easy to reverse the process.

Note: I'm using the sas.IOMProvider provider in my connectionstring.

Thanks

EDIT: After all the searching I've been doing, I assume you can't really do this. I tried using SQL parameterization, but the SAS provider doesn't support that. I finally decided to use a simple for loop to add the values since all my source and target tables contain the same columns. Semi-pseudo code:

DateTime time = (System.DateTime)exportTable.Rows[i]["time"];
object value = exportTable.Rows[i]["value"];
"INSERT INTO SASUSER." + tableName + " (time, value) VALUES (" + time.Ticks + " , " + value + ")"

I'm still having trouble with loading dates into a new SAS table using an SQL INSERT clause (see code above). Not sure how they're supposed to be formatted. The time values in the source table (exportTabl开发者_高级运维e) are DateTime objects, so the cast is valid.


Instead of trying to do it as an INSERT from the dataset, can you approach it from the opposite direction do it as an EXPORT to to the table (SASUSER.tablename)?

http://support.sas.com/documentation/cdl/en/acpcref/63184/HTML/default/viewer.htm#a003102702.htm

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜