Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
im making tow table where ineer join connect awanted to save and update an iwanted to change in my program and update it this is my cod to connect
VB
try
    cmd.CommandText = "SELECT Employee.Emp_ID ,Employee.Emp_Name ,Employee.Emp_Tel , Dep_Name FROM Employee , Department where Employee.Dep_id = Department.Dep_id "

    DataAdapter1 = New OleDbDataAdapter(cmd)
    Dim builder As New OleDbCommandBuilder(DataAdapter1)

    DataSet1 = New DataSet()

    'Load some data into the DGV
    DataAdapter1.Fill(DataSet1, "DataTable1")
    BindingSource1 = New BindingSource(DataSet1, "DataTable1")
    BindingSource2 = New BindingSource(DataSet1, "DataTable1")

    Label7.DataBindings.Add("Text",
    BindingSource1, "Emp_ID", True, 1, "")

    TextBox1.DataBindings.Add("Text", BindingSource1, "Emp_Name", True, 1, "")
    TextBox2.DataBindings.Add("Text", BindingSource1, "Emp_Tel", True, 1, "")
    TextBox3.DataBindings.Add("Text", BindingSource1, "Dep_Name", True, 1, "")
    ' TextBox4.DataBindings.Add("Text", BindingSource1, "price", True, 1, "")
    ' TextBox5.DataBindings.Add("Text", BindingSource1, "total", True, 1, "")

    DataGridView1.DataSource = BindingSource1
    ComboBox1.DataSource = BindingSource1
    ComboBox1.DisplayMember = "Emp_Name"
    ComboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend
    ComboBox1.AutoCompleteSource = AutoCompleteSource.ListItems

    DataGridView1.Columns(0).Width = 40
    DataGridView1.Columns(1).Width = 100
    DataGridView1.Columns(2).Width = 70
    DataGridView1.Columns(3).Width = 70
    ' DataGridView1.Columns(4).Width = 70
    ' DataGridView1.Columns(5).Width = 100

    DataGridView1.Columns(0).HeaderText = "?????"
    DataGridView1.Columns(1).HeaderText = "?????"
    DataGridView1.Columns(2).HeaderText = "??????"
    DataGridView1.Columns(3).HeaderText = "??????"
    ' DataGridView1.Columns(4).HeaderText = "?????"
    ' DataGridView1.Columns(5).HeaderText = "????????"

    DataGridView1.Columns(2).AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
    DataGridView1.Columns(0).ReadOnly = True
    DataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
    DataGridView1.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
    DataGridView1.Sort(DataGridView1.Columns(1), System.ComponentModel.ListSortDirection.Ascending)
    count()
Catch ex As Exception
    MessageBox.Show(ex.Message, "?????", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try

and this code make proplem to update tow taple

buton _click
VB
If BindingSource1.Count = 0 Then Beep() : Exit Sub
    BindingSource1.EndEdit()
    DataAdapter1.Update(DataSet1, "DataTable1 ")
    count()
Posted
Updated 27-Mar-13 14:55pm
v2
Comments
[no name] 27-Mar-13 20:37pm    
If there was some sort of a question or description of a problem anywhere in there, I sure missed it.

DataAdapter1.Update(DataSet1, "DataTable1 ")
The above statement is wrong. DataTable1 has a space in it. You dont have to call the table part.
You can just say Adapter.Update(DataSet).

Other reasons can be found out only if you have posted how you have provided your updation queries.
 
Share this answer
 
Comments
monemdb 28-Mar-13 20:53pm    
monem
the proplem stil happen plesa any solution about repair this code
monem

the prpplem was stil error and dont save any thing plese any one to help me to solve this proplem
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900