Updating Problem In Multiple Tables in VB.NET

Discussion in 'Software' started by Naveed_786, Jul 21, 2010.

  1. Naveed_786

    Naveed_786

    Joined:
    Jul 21, 2010
    Messages:
    1
    Dear All,

    I have designed a form for a table Instalment from this form i am trying to update a column in other table which is hiring table please guide me how can i do this the code is as folloes thanks in advance.

    Dim cnString As String

    cnString = ("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\PaymentSystem\PaymentSystem\bin\Debug\Payment.mdb;")


    Dim sqlQRY As String = "SELECT * FROM Instalment"
    'Dim sqlQRY1 As String = "UPDATE hiring(TotalAmount)SET" & _
    '" TotalAmount = " & TextBox7.Text & "WHERE PlotNo = & TextBox1.Text"
    'Dim sqlQRY1 As String = "Select * from hiring"
    'Create connection
    Dim conn As OleDbConnection = New OleDbConnection(cnString)

    Try
    ' Open connection
    conn.Open()

    'create data adapter
    Dim da As OleDbDataAdapter = New OleDbDataAdapter(sqlQRY, conn)
    Dim da1 As OleDbDataAdapter = New OleDbDataAdapter(sqlQRY1, conn)
    'create command builder
    Dim cb As OleDbCommandBuilder = New OleDbCommandBuilder(da)
    Dim cb1 As OleDbCommandBuilder = New OleDbCommandBuilder(da1)
    'create dataset
    Dim ds As DataSet = New DataSet
    Dim ds1 As DataSet = New DataSet
    'fill dataset
    da.Fill(ds, "Instalment")
    da1.Fill(ds1, "Hiring")
    'get data table
    Dim dt As DataTable = ds.Tables("Instalment")
    Dim dt1 As DataTable = ds1.Tables("Hiring")
    Dim newRow As DataRow = dt.NewRow()
    Dim newrow1 As DataRow = dt1.NewRow()
    newRow("PlotNo") = TextBox1.Text
    newRow("CustomerName") = TextBox2.Text
    newRow("Fname") = TextBox3.Text
    newRow("Area") = TextBox4.Text
    newRow("TotalAmount") = TextBox5.Text
    newRow("RecivedAmount") = TextBox6.Text
    newRow("RemainingAmount") = TextBox7.Text
    newRow("PaymentDate") = TextBox8.Text
    newRow("PaymentReciverName") = TextBox9.Text
    newrow1("TotalAmount") = TextBox7.Text
    dt.Rows.Add(newRow)
    'dt1.Rows.Add(newrow1)
    'updat Instalment and Hiring table
    If TextBox1.Text = ds.Tables("Instalment").Rows(1).Item(1) Then

    Dim sqlQRY1 As String = "UPDATE hiring(TotalAmount)SET" & _
    " TotalAmount = " & TextBox7.Text & "WHERE PlotNo = & TextBox1.Text"
    End If
    da.Update(ds, "Instalment")
    da1.Update(ds1, "Hiring")
    MsgBox("Record successfully saved...", MsgBoxStyle.Information)
    Catch ex As OleDbException
    MsgBox("Error: " & ex.ToString & vbCrLf)
    Finally
    ' Close connection
    conn.Close()
    End Try
    Naveed_786, Jul 21, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hbmath

    Problem printing tables

    hbmath, Aug 23, 2003, in forum: Firefox
    Replies:
    0
    Views:
    1,219
    hbmath
    Aug 23, 2003
  2. Kaimuri
    Replies:
    3
    Views:
    17,707
    Kaimuri
    Dec 29, 2004
  3. Serendipity

    Tables Problem

    Serendipity, Nov 21, 2003, in forum: Computer Support
    Replies:
    1
    Views:
    400
  4. ~¢makey$

    Is it possible to make multiple columns of tables?

    ~¢makey$, Nov 23, 2003, in forum: Computer Support
    Replies:
    2
    Views:
    543
    ~¢makey$
    Nov 23, 2003
  5. joewo

    Trouble updating .NET Framework

    joewo, Feb 10, 2008, in forum: Computer Support
    Replies:
    1
    Views:
    361
    Mr. Arnold
    Feb 10, 2008
Loading...

Share This Page