Jump to content

formulario nao grava na base de dados


tairone
 Share

Recommended Posts

o meu problema é que quando gravo um registo num determinado formulario, ele nao grava a informação na base de dados, apenas no datagridview. alguem sabe como resolvo este problema?

e tenho mais uma coisa, eu possuo 2 datasets no meu projecto, nao sei o que aconteceu mas de um dia para o outro começou a aparecer 2 datasets, e acho que isso ta causando conflito. como apago um dos dataset?

Link to comment
Share on other sites

este aqui é o codigo que esta no formulario onde adiciono um novo utilizador. eu so nao entendo é pq que quando eu vou gravar ele nao insere os dados nas tabelas -.-''

Public Class Novo_Jogo

    Private Sub UserBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UserBindingNavigatorSaveItem.Click
        If Me.FotoTextBox.Text <> "" Then
            FotoPictureBox.Image = Image.FromFile(Me.FotoTextBox.Text)
           
        End If
        Me.Validate()
        Me.UserBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.BDadosDataSet)
        Me.UserBindingSource.MoveFirst()
        Me.UserBindingSource.MoveLast()

    End Sub

    Private Sub Novo_Jogo_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'BDadosDataSet1.Sexo1' table. You can move, or remove it, as needed.
        Me.Sexo1TableAdapter.Fill(Me.BDadosDataSet1.Sexo1)
        'TODO: This line of code loads data into the 'BDadosDataSet1.Sexo' table. You can move, or remove it, as needed.

        'TODO: This line of code loads data into the 'BDadosDataSet.Sexo' table. You can move, or remove it, as needed.

        'TODO: This line of code loads data into the 'BDadosDataSet1.User' table. You can move, or remove it, as needed.
        Me.UserTableAdapter1.Fill(Me.BDadosDataSet1.User)
        'TODO: This line of code loads data into the 'BDadosDataSet.Tipo' table. You can move, or remove it, as needed.
        Me.TipoTableAdapter.Fill(Me.BDadosDataSet.Tipo)
        'TODO: This line of code loads data into the 'BDadosDataSet.Curso' table. You can move, or remove it, as needed.
        Me.CursoTableAdapter.Fill(Me.BDadosDataSet.Curso)
        'TODO: This line of code loads data into the 'BDadosDataSet.Nacionalidade1' table. You can move, or remove it, as needed.
        Me.Nacionalidade1TableAdapter.Fill(Me.BDadosDataSet.Nacionalidade1)
        'TODO: This line of code loads data into the 'BDadosDataSet.User' table. You can move, or remove it, as needed.
        Me.UserTableAdapter.Fill(Me.BDadosDataSet.User)
        If Me.FotoTextBox.Text <> "" Then
            FotoPictureBox.Image = Image.FromFile(Me.FotoTextBox.Text)
        End If
       
    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


        Me.OpenFileDialog1.Filter = "Imagem (*.jpg)|*.jpg|(*.gif)|*.gif|(*.bmp)|*.bmp|(*.*) |*.*"
        '"*.jpg|*.jpg;*.gif|*.gif;*.bmp|*.bmp"
        OpenFileDialog1.ShowDialog()

        If OpenFileDialog1.FileName <> "" Then
            FotoPictureBox.Image = Image.FromFile(OpenFileDialog1.FileName)
            Me.FotoTextBox.Text = OpenFileDialog1.FileName
        End If


    End Sub

    Private Sub NacionalidadeComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub CursoComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub NomeTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NomeTextBox.TextChanged

    End Sub

    Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint

    End Sub

    Private Sub FotoPictureBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FotoPictureBox.Click

    End Sub

    Private Sub NovoJogoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub SairToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SairToolStripMenuItem.Click
        LoginForm1.Show()
        Me.Hide()

    End Sub

    Private Sub CursoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CursoToolStripMenuItem.Click
        Cursos.Show()

    End Sub

    Private Sub ModulosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ModulosToolStripMenuItem.Click
        modulos.Show()

    End Sub

    Private Sub DisciplinaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DisciplinaToolStripMenuItem.Click
        disciplina.Show()

    End Sub

    Private Sub PerguntasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PerguntasToolStripMenuItem.Click
        Perguntas.Show()

    End Sub

    Private Sub RespostasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RespostasToolStripMenuItem.Click
        resposta.Show()

    End Sub

    Private Sub PasswordTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasswordTextBox.TextChanged

    End Sub


    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        Me.BindingNavigatorAddNewItem.PerformClick()
        Me.Cod_utilizadorTextBox.Text = Val(Me.UserBindingSource.Count())
        Me.NomeTextBox.Focus()
    End Sub

    Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
        Me.UserBindingNavigatorSaveItem.PerformClick()
    End Sub

    Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click
        If MsgBox("Têm a certeza que pretende apagar o registo", vbYesNo + vbQuestion, "Confirmação") = vbYes Then
            Me.BindingNavigatorDeleteItem.PerformClick()
        End If
    End Sub

    Private Sub PictureBox4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox4.Click
        MessageBox.Show("Tamanho de Imagem 109x129")
    End Sub

    Private Sub UserDataGridView_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles UserDataGridView.CellContentClick

    End Sub

    Private Sub SexoRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        'SexoTextBox.Text = 1
    End Sub

    Private Sub SexoRadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        'SexoTextBox.Text = 2
    End Sub

    Private Sub SairToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SairToolStripMenuItem1.Click
        End
    End Sub
End Class

EDIT: GeSHi adicionado

Link to comment
Share on other sites

vbYesNo ????????  Não conhecia ... Significa igual a isto MsgBoxStyle.YesNo ???

E o Impossível foi criado por pessoas fracas pra acabar com o sonho das pessoas fortes. Não deixes que acabem com o teu. Sonha , luta , ambiciona e realiza. Se amas , se gostas tu vais conseguir. Cala todas as pessoas que um dia duvidaram de ti e prova que foste mais forte de qualquer outro.

Link to comment
Share on other sites

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
 Share

×
×
  • 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.