0
I’m maintaining 1 controller and I’m taking the data from my database and trying to display it in the view, however I can’t pass select to the view, can anyone help me? i need to pass all select data in a table or in normal text.
Follow the code of my controller:
public ActionResult GetContacts()
{
SqlConnection conexao = new SqlConnection(@"Data Source="nomebd";Initial Catalog="nometabela";User ID="usuario";Password="senha"");
conexao.Open();
string strQuerySelect = "SELECT * FROM people where id > 0 and id < 100";
SqlCommand cmdComandoSelect = new SqlCommand(strQuerySelect, conexao);
SqlDataReader dados = cmdComandoSelect.ExecuteReader();
var contacts = new List<OrderViewModel>();
while (dados.Read())
{
contacts.Add(new OrderViewModel
{
id = dados["id"].ToString(),
idPessoa = Math.Round(Convert.ToDouble(dados["idPessoa"]) * 3.2, 2),
Nome = dados["nome"].ToString(),
});
}
return Json(contacts);
}
Marcelo, are you getting back into Contracts? puts a break point and hovers over, see if there are items inside it... If yes I can help you.
– Leonardo Bonetti