【发布时间】:2014-02-11 14:00:20
【问题描述】:
我正在尝试从 Visual Studio 2012 插件创建一个连接的查询窗口。
这是我正在使用的代码:
UIConnectionInfo u = new UIConnectionInfo
{
ServerName = serverName,
ServerType = new Guid(serverType),
AuthenticationType = authType
};
u.AdvancedOptions.Set("DATABASE", databaseName);
u.AdvancedOptions.Set("PACKET_SIZE", "4096");
u.AdvancedOptions.Set("CONNECTION_TIMEOUT", "15");
u.AdvancedOptions.Set("EXEC_TIMEOUT", "0");
u.AdvancedOptions.Set("ENCRYPT_CONNECTION", "False");
u.AdvancedOptions.Set("USE_CUSTOM_CONNECTION_COLOR", "False");
u.AdvancedOptions.Set("CUSTOM_CONNECTION_COLOR", "-986896");
u.ApplicationName = "Microsoft SQL Server Data Tools, T-SQL Editor";
u.UserName = userName;
if(authType == 1)
{
u.Password = password;
}
ScriptFactory scriptFactory = ScriptFactory.Instance;
if(scriptFactory != null)
{
scriptFactory.CreateNewBlankScript(ScriptType.Sql, u, null);
}
UIConnectionInfo 中的所有属性都设置为与您从 Visual Studio 2012 手动打开查询窗口时完全相同的值。
scriptFactory.FileOpenMode 设置为 Connected。
我什至尝试将打开和关闭连接的 SQLConnection 对象传递给 CreateNewBlankScript(这有助于 Visual Studio 2010),但没有结果。
在其他程序集中,我引用了 SQLEditors.dll 和 SQLWorkbench.Interfaces ,它们都是 11.0 版本。
任何信息都会很有帮助。
谢谢。
【问题讨论】:
标签: c# visual-studio-2012 visual-studio-addins new-window