Inserting data into db sql server

1

I am having problems connecting my project to the database, I do not understand the reason, I have already looked at several tutorials, I use sql server 2017, I can access db in an application, but the site is not working.

I'musingthefollowingcode

web.config

<connectionStrings><addname="SicConnectionString" connectionString ="Data Source=ETID-012312\ETID012312;User=sa;Password=admin2312;Initial Catalog=Sic_db;Integrated Security=True;" providerName = "System.Data.SqlClient" />

cadastro.cshtml     @ {     Layout="~ / _SiteLayout.cshtml";     Page.Title="Registration";

var fantasia = "";
var cnpj = "";
var cep = "";
var endereco = "";
var estado = "";
var cidade = "";
var bairro = "";
var celular = "";
var telefone = "";
var email = "";
var usuario = "";
var senha = "";
var csenha = "";
var error = false;
var resultado = "";

if (IsPost)
{
    var db = Database.OpenConnectionString("Data Source=;User=;Password=;Initial Catalog=;Integrated Security=True;");
    fantasia = Request.Form["fantasia_txv"];
    cnpj = Request.Form["cnpj_txv"];
    cep = Request.Form["cep_txv"];
    endereco = Request.Form["endereco_txv"];
    estado = Request.Form["estado_txv"];
    cidade = Request.Form["cidade_txv"];
    bairro = Request.Form["bairro_txv"];
    celular = Request.Form["celular_txv"];
    telefone = Request.Form["telefone_txv"];
    email = Request.Form["email_txv"];
    usuario = Request.Form["usuario_txv"];
    senha = Request.Form["senha_txv"];
    csenha = Request.Form["csenha_txv"];

    // Define the insert query. The values to assign to the
    // columns in the Product table are defined as parameters
    // with the VALUES keyword.

        var insertQuery = "INSERT INTO dbo.TempAcc (TA_fantasia, TA_cnpj, TA_cep, TA_endereco, TA_estado, TA_cidade, TA_bairro, TA_celular, TA_telefone, TA_email, TA_usuario, TA_senha)" +
            "VALUES (@0, @1, @2, @3, @4, @5, @6, @7, @8, @9, @10, @11)";
        db.Execute(insertQuery, fantasia, cnpj, cep, endereco, estado, cidade, bairro, celular, telefone, email, usuario, senha);
        // Display the page that lists products.

}

}

Can someone tell me where I'm going wrong? or a template to work? the ms tutorials did not work well.

    
asked by anonymous 19.10.2017 / 00:50

1 answer

1

The problem is in your connection string

<connectionStrings>
<add name="SicConnectionString" connectionString ="Data Source=ETID-012312\ETID012312;User=sa;Password=admin2312;Initial Catalog=Sic_db;Integrated Security=True;" providerName = "System.Data.SqlClient" />

Replace the "User" attribute with "User ID"

    
19.10.2017 / 16:35