Dynamically change the ip of the connection config MSSQL

Hello! i'm starting with node-Red and i have a trouble with it. I'm using MSSQL node from: node-red-contrib-mssql-plus.
image
and i want to change dinamically the ip of the connection with a flow variable it is possible? thanks

No, but you can use an ENV variable.

e.g. ${SQL_SERVER_IP}

Thanks! but its possible to change the value of this environment in a function node?

Yes, kinda, but - environment variables are only read when node-red starts.

Ps, if you don't reply directly to my post I don't get a notification - so I don't know if you've replied until I look at the forum again.

okay sorry Steve im totally new, and last question its possible to connect to sql via a function expression? i'm trying it but its not woking

When use say connect do you mean provide an IP and username etc?

It's not possible to pass in config parameters at runtime. This is the case with most config nodes unless it has been explicitly designed to accept parameters after creation.

Why do you wish to send IP address parameters? It is easy enough to modify the config node in the Node red editor

image
i want to do something like this but is not working....

Do you get an error?

Have you added mssql in settings.js function context?

Also, what is res.send supposed to do?

Lastly, you can't return msg due to async processing, you need to do node.send(msg) in the callback.

yes i did it :slight_smile:
appears this error:

Thats a problem with you coding - you will have to read the MSSQL docs

Alternatively, use mssql-plus node that has been designed to simplify life.

Looks to me as though the SQL server is wanting an SSL encrypted connection and you haven't passed it one.

Also, the instructions for the mssql module suggest that you need a sql.connect but you've used sql.Request which wants a pool or transaction as an argument, maybe not your config object?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.