Clicky

I have a small SQL database with 2 tables.
Table 1 consist of 3 columns, c1 (PK), c2, and c3 (Table2 FK)
Table 2 consist of 2 columns, c1 (PK) and c2

I am able to make a query and fill my datatable in VB using inner join on Table2.c1 and Table1.c3, but I can't figure out how to update (add/edit/delete) data on both tables at the same time.

Which command(s) will let me put the content of textbox's into the respective tables in the database?

asked 12/13/2011 12:08

rayves's gravatar image

rayves ♦♦


4 Answers:
Do you mean updating using a dataadapter or updating manually?

http://kjellsj.blogspot.com/2005/10/tableadapter-with-multiple-related.html
link

answered

CodeCruiser's gravatar image

CodeCruiser

I'm using dataadapter to retrieve the data from the database.
link

answered 2011-12-13 at 08:15:46

rayves's gravatar image

rayves

This is the code that generates the error. According to my book this is the correct way to use dataadapter on a single table, but with 2 tables I only get an error.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
Private Sub btnLagre_Click(sender As System.Object, e As System.EventArgs) Handles btnLagre.Click
        If m_Datatable.Rows.Count <> 0 Then
            m_Datatable.Rows(m_rowPosition)("post.postnr") = txtPostnr.Text
            m_Datatable.Rows(m_rowPosition)("post.sted") = txtPoststed.Text
            m_Datatable.Rows(m_rowPosition)("kunde.postnr") = txtPostnr.Text
            m_Datatable.Rows(m_rowPosition)("kunde.kundenavn") = txtKundenavn.Text
            m_da.Update(m_Datatable)

        End If
    End Sub
link

answered 2011-12-13 at 08:34:01

rayves's gravatar image

rayves

Did you try the link?
link

answered 2011-12-13 at 08:49:05

CodeCruiser's gravatar image

CodeCruiser

Your answer
[hide preview]

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×132
×2

Asked: 12/13/2011 12:08

Seen: 4532 times

Last updated: 12/17/2011 08:27