Node red can't connect sql server

Thanks Steve! It works
If it wasn't for you help , I wouldn't be able to do it. :heartbeat: :heartbeat: :heartbeat:

1 Like

how to use data msg.payload = value to push into database


Firstly, dont post picture of code (since i cannot copy & correct it for you)

```
paste code between backticks like this
```

Next, dont build queries in node - use the parameters of the MSSQL-PLUS node

example##
var value = 6
msg.payload = value
return msg
How to reteive data msg.payload = value to use

ummm that code is nothing like the 2 pictures above!
Anyhow, what I was saying was Dont build SQL Querys in code (to avoid SQL injection hacks) - use the parameters on the MSSQL-PLUS node...

image

How to use the value from the first function to the second function?

This is function 17

var steel = 6;

msg.payload = steel;

return msg;

i want to use value of steel in function 18

Since you put the value of steel inside of msg.payload it will be available in the next function in exactly the same place. E.g. put node.warn(msg.payload) inside of function 18 and you will see the number six In the debug output.

You could even put the value into a completely different property example setting msg.abc =123 In function 17 will mean the value of 123 will be available inside of msg.abc inside function 18.

Attach debug nodes to your functions and you will see exactly what the message contains. Be sure to set the debug nodes to show the complete message if you are using properties other than payload.

Do you have an example?

An example of what? You asked how you could access the value in function 18 and I told you - it will be in the exact same place that you put it.

I think you are missing some fundamental knowledge around node-red and messages etc

I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

Following that, you should probably do some experimenting like adding inject and debug nodes and seeing what you get in the debug panel. Also look at the flow library and search the forum. There are thousands of examples and demonstrations.

Once you have the basics you will see that the questions you are asking are extremely basic beginner knowledge and you should know how to answer them yourself once you have done the above.

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