Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

iforgot

Data base Call

Recommended Posts

Ola...Gostaria de saber como posso inserir uma Data Base...de preferencia Microsoft Access,,,,,,e Assim eu ja criei a data base mas agora gostaria de poder inserir a data base na minha form do visual basic....consiguo fazer isso mas nao sei como usar o codigo para salvar..de maneira que os dados nao saiam de la...fiquem todos registados...se alguem me poder ajudar estaria muito grato.... :rolleyes:

Compartilhar este post


Link para o post
Compartilhar em outros sites

Sera que alguem me poderia ajudar?Urgentemente por favor :(

Boa tarde,Cara a maneira mais simples para fazer isto é utilizando o Data Control ....Porém é uma porcaria ....Você pode utilizar o ADO para realizar a conexao com o Banco de dados...Uma dica, acesse o Site do www.Marcoratti.net e la consulte como realizar conexao com o banco de dados ...acredito que seja um bom começo para você.Um abraço.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Tenho uma duvida.....por alguma razao nao consiguo salvar...aqui tem o meu codigo.....

 

Imports System.configuration

Imports System.Data

Imports System.Data.OleDb.OleDbDataAdapter

Imports Phone_Book_List.Input

Imports System.Reflection

 

(deveser aqui o meu erro, nao sei)

 

 

Public Class Input

Private Sub Input_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

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

Me.Cost_CenterTableAdapter.Fill(Me.Phone_Book_ListDataSet.Cost_Center)

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

Me.CallSigns_TableTableAdapter.Fill(Me.Phone_Book_ListDataSet.CallSigns_Table)

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

Me.Cost_CenterTableAdapter.Fill(Me.Phone_Book_ListDataSet.Cost_Center)

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

Me.DepartmentTableAdapter.Fill(Me.Phone_Book_ListDataSet.Department)

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

Me.LocationTableAdapter.Fill(Me.Phone_Book_ListDataSet.Location)

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

Me.TrunckingTableAdapter.Fill(Me.Phone_Book_ListDataSet.Truncking)

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

Me.UserTableAdapter.Fill(Me.Phone_Book_ListDataSet.User)

 

 

'CONNECTING THE DATABASE TO THE FORM

 

Dim table As DataTable = Nothing

Dim connectionString As String = My.Settings.Phone_Book_ListConnectionString

 

Using connection As OleDb.OleDbConnection = New OleDb.OleDbConnection(connectionString) (erro---->) Connection.open() (ERRRROOOOOOOO, Nao consiguo descobrir porque que esta errado)

Dim command As OleDb.OleDbCommand = New OleDb.OleDbCommand("Select * FROM USER", connection)

Dim adapter As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(command)

table = New DataTable()

adapter.Fill(table)

End Using

GenerateForm(table)

 

End Sub

Private Sub GenerateForm(ByVal table As DataTable)

 

'GENERATE FORM TO LOAD THE DATABASE

 

Dim label As Label

Dim textbox As TextBox

Dim I As Integer

For I = 0 To table.Columns.Count - 1

label = New Label()

label.Location = New Point(10, I * 22 + 10)

label.AutoSize = True

label.Text = table.Columns(I).ColumnName + ":"

Controls.Add(label)

textbox = New TextBox

textbox.Location = New Point(100, I * 22 + 10)

textbox.Width = 200

textbox.DataBindings.Add("Text", table, table.Columns(I).ColumnName)

Controls.Add(textbox)

Next

End Sub

 

 

Private Sub savebtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles savebtn.Click

 

 

'SAVING THE FILES TO THE DATABASE (SAVE BUTTON)

 

 

 

If Me.Validate() Then

 

Me.UserBindingSource.EndEdit()

Me.UserTableAdapter.Fill(Me.Phone_Book_ListDataSet.User)

 

Else

System.Windows.Forms.MessageBox.Show(Me, "Validation erros occurred.", "Save", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning)

 

End If

 

If Me.Validate Then

Me.DepartmentBindingSource.EndEdit()

Me.DepartmentTableAdapter.Fill(Me.Phone_Book_ListDataSet.Department)

Else

System.Windows.Forms.MessageBox.Show(Me, "Validation erros occurred.", "Save", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning)

End If

 

If Me.Validate Then

Me.TrunckingBindingSource.EndEdit()

Me.TrunckingTableAdapter.Fill(Me.Phone_Book_ListDataSet.Truncking)

Else

System.Windows.Forms.MessageBox.Show(Me, "Validation erros occurred.", "Save", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning)

End If

 

If Me.Validate Then

Me.LocationBindingSource.EndEdit()

Me.LocationTableAdapter.Fill(Me.Phone_Book_ListDataSet.Location)

Else

System.Windows.Forms.MessageBox.Show(Me, "Validation erros occurred.", "Save", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning)

End If

 

If Me.Validate Then

Me.Cost_CenterBindingSource.EndEdit()

Me.Cost_CenterTableAdapter.Fill(Me.Phone_Book_ListDataSet.Cost_Center)

Else

System.Windows.Forms.MessageBox.Show(Me, "Validation erros occurred.", "Save", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning)

End If

 

If Me.Validate Then

Me.CallSigns_TableBindingSource.EndEdit()

Me.CallSigns_TableTableAdapter.Fill(Me.Phone_Book_ListDataSet.CallSigns_Table)

Else

System.Windows.Forms.MessageBox.Show(Me, "Validation erros occurred.", "Save", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning)

End If

 

 

End Sub

 

Private Sub exitbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitbtn.Click

 

' CLOSE APLICATION (EXIT BUTTON)

 

Dim btExit As String

 

btExit = MessageBox.Show("Are you sure ?", "Exit Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button3)

If btExit = Windows.Forms.DialogResult.Yes Then

Me.Close()

End If

 

 

End Sub

 

 

 

Alguem Consegue ajudar?

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.