简体   繁体   中英

How to construct connect mssql command with variable in Polyglot Notebook

How to construct a magic connect command with variable? For example with a variable value as myserver.

#!value --name sqlserver myserver

#;share sqlserver --from value string sqlconnstr = $"Server={sqlserver}; Initial Catalog=mydb; Persist Security Info=False; Integrated Security=true;"; #!connect mssql --kernel-name mydb sqlconnstr

This doesn't work.

Expecting to have something similar that can take a variable like this static command that works,

#;connect mssql --kernel-name mydb "Server=myserver; Initial Catalog=mydb; Persist Security Info=False; Integrated Security=true;"

Received clarification from .net interactive contributor.

Values from other kernels can be inlined with the syntax @kernelName:variableName so in your scenario it could look something like this:

#:connect mssql --kernel-name mydb @csharp:sqlconnstr

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM