3
我想从Visual Studio 2012插件创建连接的查询窗口。从Visual Studio 2012插件创建连接的查询窗口
这是我使用的代码:当你从Visual Studio 2012
scriptFactory.FileOpenMode manualy打开一个查询窗口,
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所有属性都设置为精确值被设置为连接。
我甚至试图通过打开和关闭连接到CreateNewBlankScript(这有助于Visual Studio 2010)的SQLConnection对象,但没有结果。
在其他程序集中,我引用了SQLEditors.dll和SQLWorkbench.Interfaces,均为11.0版本。
任何信息将非常有帮助。
谢谢。