尝试将元素作为与数组不兼容的类型进行访问

时间:2016-05-12 16:50:24

标签: c# smo

以下代码给出了错误:

  

尝试将元素作为与数组不兼容的类型进行访问。

using System.Collections.Generic;
using System.Data.SqlClient;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Sdk.Sfc;
using Microsoft.SqlServer.Management.Smo;

var database = server.Databases["mydemotest"];

var scripter = new Scripter(server);
scripter.Options.IncludeIfNotExists = true;
scripter.Options.ScriptSchema = true;
scripter.Options.ScriptData = true;

string scrs = "";
string tbScr = "";
foreach (Table myTable in database.Tables)
{
    if (myTable.IsSystemObject == true) continue;

    IEnumerable<string> tableScripts = scripter.EnumScript(new Urn[] { myTable.Urn });

    foreach (string script in tableScripts)
        scrs += script + "\n\n";
}

return (scrs + "\n\n" + tbScr);
此行IEnumerable<string> tableScripts = scripter.EnumScript(new Urn[] { myTable.Urn });

例外情况 ArrayTypeMismatchException的任何帮助?

0 个答案:

没有答案