Empacado no Vb!!!
Ola, pessoal.
estou iniciando na programação, Estou apredendo a linguagem Vb. No curso que estou fazendo estamos trbalhando em um projeto que existe um banco de dados SQl
e a plicação faz uma conexão com o mesmo. Mas estou tendo alguns problemas, na hora de inserir dados pelo formulario. Ja tentei de tudo,
fiz varias pesquisas na net e não consegui encontrar nada. Se alguem poder me ajudar?
O codigo que fiz esta assim:
Private Sub btnGravar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGravar.Click
Dim SqlCmd As SqlCommand
Dim Resultado As Int32
Dim StrSql As String
Conectar()
StrSql = "insert funcionario"
StrSql = StrSql & "matricula_func = " & txtMatricula.Text.Trim & ","
StrSql = StrSql & "nome_func = " & txtNome.Text.Trim & ","
StrSql = StrSql & "cpf_func = " & mskCpf.Text.Trim & ","
StrSql = StrSql & "rg_func = " & mskRg.Text.Trim & ","
StrSql = StrSql & "rua_end_func = " & txtAvrua.Text.Trim & ","
StrSql = StrSql & "nr_end_func = " & txtNr.Text.Trim & ","
StrSql = StrSql & "compl_end_func = " & txtComplemento.Text.Trim & ","
StrSql = StrSql & "bairro_func = " & txtBairro.Text.Trim & ","
StrSql = StrSql & "cidade_func = " & txtCidade.Text.Trim & ","
StrSql = StrSql & "cep_end_func = " & mskCep.Text.Trim & ","
StrSql = StrSql & "codigo_uf = " & cmbUf.SelectedIndex & ","
StrSql = StrSql & "ddd_res_func = " & txtDddres.Text.Trim & ","
StrSql = StrSql & "fone_res_func = " & txtFoneres.Text.Trim & ","
StrSql = StrSql & "ddd_cel_func = " & txtFonecel.Text.Trim & ","
StrSql = StrSql & "sexom_func = " & rdbSexom.Checked & ","
StrSql = StrSql & "sexof_func = " & rdbSexof.Checked & ","
StrSql = StrSql & "est_civil_func = " & cmbEstacivil.SelectedIndex & ","
StrSql = StrSql & "dependentes_func = " & cmbDependentes.SelectedIndex & ","
StrSql = StrSql & "codigo_cargo = " & cmbCargo.SelectedIndex & ","
StrSql = strSql & "func_ativo = " & ckbativo.Checked & "," 'Isto é uma checkbox
StrSql = StrSql & "salario_func = " & txtSalario.Text.Trim
SqlCmd = New SqlCommand(StrSql, AdoConn)
Resultado = SqlCmd.ExecuteNonQuery
Desconectar()
LimparCampos()
Se alguem poder me dizer onde esta o erro (imagino que tenha aos montes), poderia me dizer e me passar
como poderia estar fazendo.
Desde ja obrigado. Abraços!!!
__________________
Jogando: Pac-Man, Enduro, River Ride
|