How to use the azdata.queryeditor function in azdata

To help you get started, we’ve selected a few azdata examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dzsquared / sqlops-firstresponderkit / src / placescript.ts View on Github external
try {
            var connectId;
            if (context) {
                let connection = context.connectionProfile;
                connectId = connection.id;
            } else {
                let connection = await sqlops.connection.getCurrentConnection();
                connectId = connection.connectionId;
            }
            let doc = await vscode.workspace.openTextDocument(setting);
            let editor = await vscode.window.showTextDocument(doc, 1, false);
            editor.edit(edit => {
                edit.insert(new vscode.Position(0, 0), scriptText);
            });
            if (connectId) {
                await sqlops.queryeditor.connect(doc.uri.toString(), connectId);
            }
        } catch (err) {
            vscode.window.showErrorMessage(err);
        }
    }
}
github dzsquared / query-editor-boost / src / placescript.ts View on Github external
editor.selection = newSelection;
            }

            if ((context || connection) && this.connectionId) { 
                if (this.dbName !== '') {
                    var providerName:string;
                    if (context) {
                        providerName = context.connectionProfile.providerName;
                    } else if (connection) {
                        providerName = connection.providerId;
                    }
                    let dProvider = await sqlops.dataprotocol.getProvider(providerName, sqlops.DataProviderType.ConnectionProvider);            
                    let connectionUri = await sqlops.connection.getUriForConnection(this.connectionId);
                    await dProvider.changeDatabase(connectionUri,this.dbName);
                }
                await sqlops.queryeditor.connect(doc.uri.toString(), this.connectionId);
            }
        } catch (err) {
            vscode.window.showErrorMessage(err);
        }
    }
github dzsquared / query-editor-boost / src / connectHolder.ts View on Github external
export async function utilizeConnection(doc: vscode.TextDocument, actualConnectionInfo: actualConnectionInfo) {
        if ( actualConnectionInfo.connectHoldId ) { 
            if (actualConnectionInfo.dbName !== '') {
                let dProvider = await azdata.dataprotocol.getProvider(actualConnectionInfo.providerId, azdata.DataProviderType.ConnectionProvider);            
                let connectionUri = await azdata.connection.getUriForConnection(actualConnectionInfo.connectHoldId);
                await dProvider.changeDatabase(connectionUri,actualConnectionInfo.dbName);
                await azdata.queryeditor.connect(doc.uri.toString(), actualConnectionInfo.connectHoldId);
            }
        }

    }
github dzsquared / query-editor-boost / src / changeDatabase.ts View on Github external
export async function changeDatabase(databaseList, connection) {
    let connectionUri = await azdata.connection.getUriForConnection(connection.connectionId);
    let dProvider = await azdata.dataprotocol.getProvider(connection.providerId, azdata.DataProviderType.ConnectionProvider);
    
    if (dProvider.providerId == "MSSQL") {
        let selectedDatabase = await vscode.window.showQuickPick(databaseList, 
            { placeHolder: 'Select Database', "ignoreFocusOut": true}
        );
        let useThisDB = selectedDatabase;
        
        await dProvider.changeDatabase(connectionUri,useThisDB);
        await azdata.queryeditor.connect(vscode.window.activeTextEditor.document.uri.toString(), connection.connectionId);
    } else {
        vscode.window.showErrorMessage("Sorry, use database is only supported for MS SQL");
    }
};

azdata

The azdata NPM module provides Azure Data Studio extension authors tools to write extensions. It provides the azdata.d.ts node module (all accessible API for extensions) as well as commands for compiling and testing extensions.

MIT
Latest version published 6 years ago

Package Health Score

63 / 100
Full package analysis