How do I show data in RAZOR MVC ASP.NET from SQL?

0

I have a SQL statement:

var motivo = conexion.Query("SELECT * FROM historialvisitas WHERE idvisita ='"+rgtro+"' ");

This table has several columns, how do I show via RAZOR @ the value of a specific column?

Example:

I want to show the values of the column motivovisita within a div , I do something like this: "between divs"

<div> @motivo </div> and <div> @motivo.motivovisita </div>

But no, it's wrong. What can I do?

    
asked by Atejada 14.03.2017 в 21:25
source

1 answer

2

To escape the character @ is with another @ :

When generating the query of SQL you will have to design a method or a something so that finding a @ will concatenate another one.

Note: your dynamic query is susceptible to SQL Injection , I'm not completely sure if the Query method is custom or part of a library, but you should follow the recommendations of the official documentation .

    
answered by 14.03.2017 в 23:35