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")
- Catch ex As OleDbException
- Finally
- ' Close connection
- End Try
- Add new comment
- 3 views