ricardoM92 Posted May 5, 2011 at 08:45 PM Report #385742 Posted May 5, 2011 at 08:45 PM 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
Andrepereira9 Posted May 5, 2011 at 08:51 PM Report #385745 Posted May 5, 2011 at 08:51 PM 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.
ricardoM92 Posted May 5, 2011 at 08:59 PM Author Report #385747 Posted May 5, 2011 at 08:59 PM :s obrigado sou novato nisto :\
ricardoM92 Posted May 5, 2011 at 09:12 PM Author Report #385750 Posted May 5, 2011 at 09:12 PM continua sem funcionar :S
Caça Posted May 5, 2011 at 09:14 PM Report #385753 Posted May 5, 2011 at 09:14 PM Porque é que não usas parâmetros? Se está a dar erro mostra-nos o erro. Pedro Martins Não respondo a duvidas por PM
kongas Posted May 5, 2011 at 09:16 PM Report #385755 Posted May 5, 2011 at 09:16 PM 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....
ricardoM92 Posted May 5, 2011 at 09:46 PM Author Report #385783 Posted May 5, 2011 at 09:46 PM diz que : ExecuteNonQuery: A propriedade Connection não foi inicializada.
kongas Posted May 5, 2011 at 09:52 PM Report #385786 Posted May 5, 2011 at 09:52 PM tens a ligação a funcionar bem com a BD? Tens mais algum comando já a interagir com a BD?
Caça Posted May 5, 2011 at 09:53 PM Report #385787 Posted May 5, 2011 at 09:53 PM Coloca está linha antes do ExecuteNonQuery cmd.connection = lig; Pedro Martins Não respondo a duvidas por PM
ricardoM92 Posted May 5, 2011 at 10:29 PM Author Report #385805 Posted May 5, 2011 at 10:29 PM é isso mesmo, muito obrigado a todos =D
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now