SQL Insert Syntax

0
hi i am trying to insert data into SQL from mendix app. i am able to fetch the data from SQL successfully using Execute Query. As i can see to run DML Operation i have to use Excute Statement tool, i have used this to insert data into sql. my sql query is as follows “insert into dbo.Employee_Details(name,mobileno) values(Example,9876543210)” but i am getting error as “Invalid column name ‘Example’ ” but here the example is value not a column name.  the name and mobileno are of varchar datatype. i have even tried with this query as well “insert into dbo.Employee_Details(name,mobileno) values(“Example”,”9876543210”)” but stills shows the sams error. can anyone help me out please?
asked
1 answers
0

Hi Mohd,

 

Apparently you succeeded connecting to your database, well done! Reading the query, it seems a Mendix Database, so that raises the question why you would want to manipulate a Mendix database using a SQL query. Generally, I would advise not to do this, but preferably use Mendix default activities in the microflow.

I'm curious why you want to manipulate data in a different database than the Mendix database, as this requires a lot more effort to make this secure.

 

To answer your question, the value “Example” is probably a string, so should be encapsuled by quotes, probably single quotes. To insert a single quote in a Mendix expression, you need to type two single quotes. So, your query expression becomes:

'insert into dbo.Employee_Details(name,mobileno) values(''Example'',9876543210)'

 

Good luck!

answered