Jump to content

Recommended Posts

Posted

lig.Open();
            OleDbCommand cmd = new OleDbCommand("INSERT INTO Vencimentos(quantia,Desc_IRS,Desc_SS,cod_funcionario) VALUES (" + txtbsalliq.Text + "," + txtbdescirs.Text + "," + txtbdescsg.Text + "," + cbfuncionario.SelectedValue + ")");
          lig.Close();

boas . . . estou a utilizar esse codigo para inserir, mas não insere :S

podem ajudar-me? :S

obrigado []s

Posted

boas

Faltam-te umas plicas, antes e depois dos parênteses dos campos com os valores a adicionar

OleDbCommand cmd = new OleDbCommand("INSERT INTO Vencimentos(quantia,Desc_IRS,Desc_SS,cod_funcionario) VALUES ('" + txtbsalliq.Text + "', '" + txtbdescirs.Text + "', '" + txtbdescsg.Text + "', '" + cbfuncionario.SelectedValue + "')");

A informática chegou para resolver problemas que antes não existiam

Quem ri por último é porque está conectado a 52 Kbs.

Posted

Boas!

tenta:

lig.Open();
            OleDbCommand cmd = new OleDbCommand("INSERT INTO Vencimentos ([quantia],[Desc_IRS],[Desc_SS],[cod_funcionario]) VALUES (@Quantia, @Desc_IRS, @Desc_SS, @CodFuncionario)");
            cmd.Parameters.Clear();
            cmd.Parameters.AddWithValue("@Quantia", txtbsalliq.Text);
            cmd.Parameters.AddWithValue("@Desc_IRS", txtbdescirs.Text);
            cmd.Parameters.AddWithValue("@Desc_SS", txtbdescsg.Text);
            cmd.Parameters.AddWithValue("@CodFuncionario", cbfuncionario.SelectedValue);

            cmd.ExecuteNonQuery();

            lig.Close();

isto não foi testado, mas tenta....

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.