Updating Oracle database


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Updating Oracle database

  1. #1
    Hari Guest

    Updating Oracle database


    Hi,
    I'm new to VB.Net. Based on the knowledge from books and sites I tried the
    below code to update an Oracle table from a windows forms application in
    VB.Net. In the below case I've a primary key defined for the "Party" table
    and I can see it on Server Explorer but when I try to issue a "find" command
    it gives me error saying that primary key not defined.

    Can anyone help me out.

    Imports System.Data
    Imports System.Data.OleDb
    Public Class frmParty
    Inherits System.Windows.Forms.Form

    Friend WithEvents bmb As BindingManagerBase

    Dim dsFfsParty As New DataSet()
    Dim cnFfs As New OleDbConnection("Provider=MSDAORA.1;Password=ffs;User
    ID=ffs;Data Source=www")
    Dim daFfsParty As New OleDbDataAdapter("SELECT * FROM party", cnFfs)
    Private Sub frmParty_Load(ByVal sender As Object, ByVal e As System.EventArgs)
    Handles MyBase.Load
    CreateDataSet()
    InitializeBinding()
    End Sub

    Sub CreateDataSet()
    Try
    cnFfs.Open()
    daFfsParty.FillSchema(dsFfsParty, SchemaType.Source, "Party")
    daFfsParty.Fill(Me.dsFfsParty, "party")
    Catch ffsFillException As System.Exception
    Throw ffsFillException
    Finally
    cnFfs.Close()
    End Try
    End Sub

    Sub InitializeBinding()
    '**** Binding code goes here

    End Sub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Handles btnSave.Click

    '*** Updating the Datasource with the help of a DataSet
    Dim tblParty As DataTable
    tblParty = dsFfsParty.Tables("Party")
    Dim drCurrent As DataRow
    drCurrent = dsFfsParty.Tables("Party").Rows.Find(TxtCode.Text)
    'drCurrent = tblParty.Rows.Find(TxtCode.Text)
    drCurrent.BeginEdit()
    drCurrent("Phone") = txtPhone.Text
    drCurrent.EndEdit()

    Dim objCommandBuilder As New OleDbCommandBuilder(daFfsParty)
    daFfsParty.Update(dsFfsParty, "Party")


    End Sub
    End Class

  2. #2
    VBDotNet Team [MS] Guest

    Re: Updating Oracle database

    You need to explicity add a primary key to the dataTable object. Add this
    piece of code before you do a find on the primary key.

    With tblParty
    .PrimaryKey = New DataColumn() _
    {.Columns("PKeyColumn")}
    End With

    Hope this helps.
    Hema Nagarajan
    VB .NET Team

    --
    This posting is provided "AS IS" with no warranties, and confers no rights.
    "Hari" <hkpillai@emirates.net.ae> wrote in message
    news:3dfec27d$1@tnews.web.devx.com...
    >
    > Hi,
    > I'm new to VB.Net. Based on the knowledge from books and sites I tried the
    > below code to update an Oracle table from a windows forms application in
    > VB.Net. In the below case I've a primary key defined for the "Party" table
    > and I can see it on Server Explorer but when I try to issue a "find"

    command
    > it gives me error saying that primary key not defined.
    >
    > Can anyone help me out.
    >
    > Imports System.Data
    > Imports System.Data.OleDb
    > Public Class frmParty
    > Inherits System.Windows.Forms.Form
    >
    > Friend WithEvents bmb As BindingManagerBase
    >
    > Dim dsFfsParty As New DataSet()
    > Dim cnFfs As New OleDbConnection("Provider=MSDAORA.1;Password=ffs;User
    > ID=ffs;Data Source=www")
    > Dim daFfsParty As New OleDbDataAdapter("SELECT * FROM party", cnFfs)
    > Private Sub frmParty_Load(ByVal sender As Object, ByVal e As

    System.EventArgs)
    > Handles MyBase.Load
    > CreateDataSet()
    > InitializeBinding()
    > End Sub
    >
    > Sub CreateDataSet()
    > Try
    > cnFfs.Open()
    > daFfsParty.FillSchema(dsFfsParty, SchemaType.Source, "Party")
    > daFfsParty.Fill(Me.dsFfsParty, "party")
    > Catch ffsFillException As System.Exception
    > Throw ffsFillException
    > Finally
    > cnFfs.Close()
    > End Try
    > End Sub
    >
    > Sub InitializeBinding()
    > '**** Binding code goes here
    >
    > End Sub
    >
    > Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As

    System.EventArgs)
    > Handles btnSave.Click
    >
    > '*** Updating the Datasource with the help of a DataSet
    > Dim tblParty As DataTable
    > tblParty = dsFfsParty.Tables("Party")
    > Dim drCurrent As DataRow
    > drCurrent = dsFfsParty.Tables("Party").Rows.Find(TxtCode.Text)
    > 'drCurrent = tblParty.Rows.Find(TxtCode.Text)
    > drCurrent.BeginEdit()
    > drCurrent("Phone") = txtPhone.Text
    > drCurrent.EndEdit()
    >
    > Dim objCommandBuilder As New OleDbCommandBuilder(daFfsParty)
    > daFfsParty.Update(dsFfsParty, "Party")
    >
    >
    > End Sub
    > End Class




  3. #3
    Hari Guest

    Re: Updating Oracle database


    Hi,
    Thanks a ton for the help. The problem of the "find" error is sorted out
    but I still could not update the table. It showed the following error.

    "Dynamic SQL generation for the UpdateCommand is not supported against a
    SelectCommand that does not return any key column information."

    Now my code reads as follows:

    Dim tblParty As DataTable
    tblParty = dsFfsParty.Tables("Party")
    With tblParty
    .PrimaryKey = New DataColumn() _
    {.Columns("partycode")}
    End With
    Dim drCurrent As DataRow
    drCurrent = dsFfsParty.Tables("Party").Rows.Find(TxtCode.Text)
    drCurrent = tblParty.Rows.Find(TxtCode.Text)
    drCurrent.BeginEdit()
    drCurrent("Phone") = txtPhone.Text
    drCurrent.EndEdit()

    Dim objCommandBuilder As New OleDbCommandBuilder(daFfsParty)
    Try
    daFfsParty.Update(dsFfsParty, "Party")
    Catch effsupdate As System.Exception
    Throw effsupdate
    End Try

    The error comes after issuing the update command. Pls help me on this.

    Rgds
    Hari.


    "VBDotNet Team [MS]" <vbdotnet@microsoft.com> wrote:
    >You need to explicity add a primary key to the dataTable object. Add this
    >piece of code before you do a find on the primary key.
    >
    > With tblParty
    > .PrimaryKey = New DataColumn() _
    > {.Columns("PKeyColumn")}
    > End With
    >
    >Hope this helps.
    >Hema Nagarajan
    >VB .NET Team
    >
    >--
    >This posting is provided "AS IS" with no warranties, and confers no rights.
    >"Hari" <hkpillai@emirates.net.ae> wrote in message
    >news:3dfec27d$1@tnews.web.devx.com...
    >>
    >> Hi,
    >> I'm new to VB.Net. Based on the knowledge from books and sites I tried

    the
    >> below code to update an Oracle table from a windows forms application

    in
    >> VB.Net. In the below case I've a primary key defined for the "Party" table
    >> and I can see it on Server Explorer but when I try to issue a "find"

    >command
    >> it gives me error saying that primary key not defined.
    >>
    >> Can anyone help me out.
    >>
    >> Imports System.Data
    >> Imports System.Data.OleDb
    >> Public Class frmParty
    >> Inherits System.Windows.Forms.Form
    >>
    >> Friend WithEvents bmb As BindingManagerBase
    >>
    >> Dim dsFfsParty As New DataSet()
    >> Dim cnFfs As New OleDbConnection("Provider=MSDAORA.1;Password=ffs;User
    >> ID=ffs;Data Source=www")
    >> Dim daFfsParty As New OleDbDataAdapter("SELECT * FROM party", cnFfs)
    >> Private Sub frmParty_Load(ByVal sender As Object, ByVal e As

    >System.EventArgs)
    >> Handles MyBase.Load
    >> CreateDataSet()
    >> InitializeBinding()
    >> End Sub
    >>
    >> Sub CreateDataSet()
    >> Try
    >> cnFfs.Open()
    >> daFfsParty.FillSchema(dsFfsParty, SchemaType.Source, "Party")
    >> daFfsParty.Fill(Me.dsFfsParty, "party")
    >> Catch ffsFillException As System.Exception
    >> Throw ffsFillException
    >> Finally
    >> cnFfs.Close()
    >> End Try
    >> End Sub
    >>
    >> Sub InitializeBinding()
    >> '**** Binding code goes here
    >>
    >> End Sub
    >>
    >> Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As

    >System.EventArgs)
    >> Handles btnSave.Click
    >>
    >> '*** Updating the Datasource with the help of a DataSet
    >> Dim tblParty As DataTable
    >> tblParty = dsFfsParty.Tables("Party")
    >> Dim drCurrent As DataRow
    >> drCurrent = dsFfsParty.Tables("Party").Rows.Find(TxtCode.Text)
    >> 'drCurrent = tblParty.Rows.Find(TxtCode.Text)
    >> drCurrent.BeginEdit()
    >> drCurrent("Phone") = txtPhone.Text
    >> drCurrent.EndEdit()
    >>
    >> Dim objCommandBuilder As New OleDbCommandBuilder(daFfsParty)
    >> daFfsParty.Update(dsFfsParty, "Party")
    >>
    >>
    >> End Sub
    >> End Class

    >
    >



  4. #4
    VBDotNet Team [MS] Guest

    Re: Updating Oracle database

    Hi Hari,
    Check the updateCommand, SelectCommand and DeleteCommand properties of
    daFfsParty. The problem here is that the select command query does not
    return the primary column data for the table. Change the selectCommand so as
    to return the primary column data as well. Let us know of this still does
    not help.

    Hema Nagarajan
    VB .NET Team

    --
    This posting is provided "AS IS" with no warranties, and confers no rights.
    "Hari" <hkpillai@emirates.net.ae> wrote in message
    news:3dfff862$1@tnews.web.devx.com...
    >
    > Hi,
    > Thanks a ton for the help. The problem of the "find" error is sorted out
    > but I still could not update the table. It showed the following error.
    >
    > "Dynamic SQL generation for the UpdateCommand is not supported against a
    > SelectCommand that does not return any key column information."
    >
    > Now my code reads as follows:
    >
    > Dim tblParty As DataTable
    > tblParty = dsFfsParty.Tables("Party")
    > With tblParty
    > .PrimaryKey = New DataColumn() _
    > {.Columns("partycode")}
    > End With
    > Dim drCurrent As DataRow
    > drCurrent = dsFfsParty.Tables("Party").Rows.Find(TxtCode.Text)
    > drCurrent = tblParty.Rows.Find(TxtCode.Text)
    > drCurrent.BeginEdit()
    > drCurrent("Phone") = txtPhone.Text
    > drCurrent.EndEdit()
    >
    > Dim objCommandBuilder As New OleDbCommandBuilder(daFfsParty)
    > Try
    > daFfsParty.Update(dsFfsParty, "Party")
    > Catch effsupdate As System.Exception
    > Throw effsupdate
    > End Try
    >
    > The error comes after issuing the update command. Pls help me on this.
    >
    > Rgds
    > Hari.
    >
    >
    > "VBDotNet Team [MS]" <vbdotnet@microsoft.com> wrote:
    > >You need to explicity add a primary key to the dataTable object. Add this
    > >piece of code before you do a find on the primary key.
    > >
    > > With tblParty
    > > .PrimaryKey = New DataColumn() _
    > > {.Columns("PKeyColumn")}
    > > End With
    > >
    > >Hope this helps.
    > >Hema Nagarajan
    > >VB .NET Team
    > >
    > >--
    > >This posting is provided "AS IS" with no warranties, and confers no

    rights.
    > >"Hari" <hkpillai@emirates.net.ae> wrote in message
    > >news:3dfec27d$1@tnews.web.devx.com...
    > >>
    > >> Hi,
    > >> I'm new to VB.Net. Based on the knowledge from books and sites I tried

    > the
    > >> below code to update an Oracle table from a windows forms application

    > in
    > >> VB.Net. In the below case I've a primary key defined for the "Party"

    table
    > >> and I can see it on Server Explorer but when I try to issue a "find"

    > >command
    > >> it gives me error saying that primary key not defined.
    > >>
    > >> Can anyone help me out.
    > >>
    > >> Imports System.Data
    > >> Imports System.Data.OleDb
    > >> Public Class frmParty
    > >> Inherits System.Windows.Forms.Form
    > >>
    > >> Friend WithEvents bmb As BindingManagerBase
    > >>
    > >> Dim dsFfsParty As New DataSet()
    > >> Dim cnFfs As New

    OleDbConnection("Provider=MSDAORA.1;Password=ffs;User
    > >> ID=ffs;Data Source=www")
    > >> Dim daFfsParty As New OleDbDataAdapter("SELECT * FROM party",

    cnFfs)
    > >> Private Sub frmParty_Load(ByVal sender As Object, ByVal e As

    > >System.EventArgs)
    > >> Handles MyBase.Load
    > >> CreateDataSet()
    > >> InitializeBinding()
    > >> End Sub
    > >>
    > >> Sub CreateDataSet()
    > >> Try
    > >> cnFfs.Open()
    > >> daFfsParty.FillSchema(dsFfsParty, SchemaType.Source,

    "Party")
    > >> daFfsParty.Fill(Me.dsFfsParty, "party")
    > >> Catch ffsFillException As System.Exception
    > >> Throw ffsFillException
    > >> Finally
    > >> cnFfs.Close()
    > >> End Try
    > >> End Sub
    > >>
    > >> Sub InitializeBinding()
    > >> '**** Binding code goes here
    > >>
    > >> End Sub
    > >>
    > >> Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As

    > >System.EventArgs)
    > >> Handles btnSave.Click
    > >>
    > >> '*** Updating the Datasource with the help of a DataSet
    > >> Dim tblParty As DataTable
    > >> tblParty = dsFfsParty.Tables("Party")
    > >> Dim drCurrent As DataRow
    > >> drCurrent = dsFfsParty.Tables("Party").Rows.Find(TxtCode.Text)
    > >> 'drCurrent = tblParty.Rows.Find(TxtCode.Text)
    > >> drCurrent.BeginEdit()
    > >> drCurrent("Phone") = txtPhone.Text
    > >> drCurrent.EndEdit()
    > >>
    > >> Dim objCommandBuilder As New OleDbCommandBuilder(daFfsParty)
    > >> daFfsParty.Update(dsFfsParty, "Party")
    > >>
    > >>
    > >> End Sub
    > >> End Class

    > >
    > >

    >




  5. #5
    Hari Guest

    Re: Updating Oracle database


    Hi Hema,

    Thanx for the response.

    I have defined a primary key (partycode) in my table party and in the serverexplorer
    I can see that. But I don't know why the primary key is not coming into the
    dataset eventhough I use "daFfsParty.FillSchema(dsFfsParty,
    SchemaType.Source, "Party")". I'm defining a primary key in the code below
    is because I'm getting an error when I use find() method as suggested by
    you. I've no idea why the primary key is not getting reflected here.
    when I checked the selectcommand property it is showing
    "Select * from party"

    I tried debuggin using the following code. and as soon as it comes to the
    GetUpdateCommand it gives me the same error.

    daFfsParty.UpdateCommand = objCommandBuilder.GetUpdateCommand
    daFfsParty.InsertCommand = objCommandBuilder.GetInsertCommand
    daFfsParty.DeleteCommand = objCommandBuilder.GetDeleteCommand
    sel = daFfsParty.SelectCommand.CommandText
    upd = daFfsParty.UpdateCommand.CommandText
    ins = daFfsParty.InsertCommand.CommandText
    del = daFfsParty.DeleteCommand.CommandText

    Any help pls.

    Rgds
    Hari.

    waiting for ur response.

    Rgds
    Hari.
    "VBDotNet Team [MS]" <vbdotnet@microsoft.com> wrote:
    >Hi Hari,
    >Check the updateCommand, SelectCommand and DeleteCommand properties of
    >daFfsParty. The problem here is that the select command query does not
    >return the primary column data for the table. Change the selectCommand so

    as
    >to return the primary column data as well. Let us know of this still does
    >not help.
    >
    >Hema Nagarajan
    >VB .NET Team
    >
    >--
    >This posting is provided "AS IS" with no warranties, and confers no rights.
    >"Hari" <hkpillai@emirates.net.ae> wrote in message
    >news:3dfff862$1@tnews.web.devx.com...
    >>
    >> Hi,
    >> Thanks a ton for the help. The problem of the "find" error is sorted out
    >> but I still could not update the table. It showed the following error.
    >>
    >> "Dynamic SQL generation for the UpdateCommand is not supported against

    a
    >> SelectCommand that does not return any key column information."
    >>
    >> Now my code reads as follows:
    >>
    >> Dim tblParty As DataTable
    >> tblParty = dsFfsParty.Tables("Party")
    >> With tblParty
    >> .PrimaryKey = New DataColumn() _
    >> {.Columns("partycode")}
    >> End With
    >> Dim drCurrent As DataRow
    >> drCurrent = dsFfsParty.Tables("Party").Rows.Find(TxtCode.Text)
    >> drCurrent = tblParty.Rows.Find(TxtCode.Text)
    >> drCurrent.BeginEdit()
    >> drCurrent("Phone") = txtPhone.Text
    >> drCurrent.EndEdit()
    >>
    >> Dim objCommandBuilder As New OleDbCommandBuilder(daFfsParty)
    >> Try
    >> daFfsParty.Update(dsFfsParty, "Party")
    >> Catch effsupdate As System.Exception
    >> Throw effsupdate
    >> End Try
    >>
    >> The error comes after issuing the update command. Pls help me on this.
    >>
    >> Rgds
    >> Hari.
    >>
    >>
    >> "VBDotNet Team [MS]" <vbdotnet@microsoft.com> wrote:
    >> >You need to explicity add a primary key to the dataTable object. Add

    this
    >> >piece of code before you do a find on the primary key.
    >> >
    >> > With tblParty
    >> > .PrimaryKey = New DataColumn() _
    >> > {.Columns("PKeyColumn")}
    >> > End With
    >> >
    >> >Hope this helps.
    >> >Hema Nagarajan
    >> >VB .NET Team
    >> >
    >> >--
    >> >This posting is provided "AS IS" with no warranties, and confers no

    >rights.
    >> >"Hari" <hkpillai@emirates.net.ae> wrote in message
    >> >news:3dfec27d$1@tnews.web.devx.com...
    >> >>
    >> >> Hi,
    >> >> I'm new to VB.Net. Based on the knowledge from books and sites I tried

    >> the
    >> >> below code to update an Oracle table from a windows forms application

    >> in
    >> >> VB.Net. In the below case I've a primary key defined for the "Party"

    >table
    >> >> and I can see it on Server Explorer but when I try to issue a "find"
    >> >command
    >> >> it gives me error saying that primary key not defined.
    >> >>
    >> >> Can anyone help me out.
    >> >>
    >> >> Imports System.Data
    >> >> Imports System.Data.OleDb
    >> >> Public Class frmParty
    >> >> Inherits System.Windows.Forms.Form
    >> >>
    >> >> Friend WithEvents bmb As BindingManagerBase
    >> >>
    >> >> Dim dsFfsParty As New DataSet()
    >> >> Dim cnFfs As New

    >OleDbConnection("Provider=MSDAORA.1;Password=ffs;User
    >> >> ID=ffs;Data Source=www")
    >> >> Dim daFfsParty As New OleDbDataAdapter("SELECT * FROM party",

    >cnFfs)
    >> >> Private Sub frmParty_Load(ByVal sender As Object, ByVal e As
    >> >System.EventArgs)
    >> >> Handles MyBase.Load
    >> >> CreateDataSet()
    >> >> InitializeBinding()
    >> >> End Sub
    >> >>
    >> >> Sub CreateDataSet()
    >> >> Try
    >> >> cnFfs.Open()
    >> >> daFfsParty.FillSchema(dsFfsParty, SchemaType.Source,

    >"Party")
    >> >> daFfsParty.Fill(Me.dsFfsParty, "party")
    >> >> Catch ffsFillException As System.Exception
    >> >> Throw ffsFillException
    >> >> Finally
    >> >> cnFfs.Close()
    >> >> End Try
    >> >> End Sub
    >> >>
    >> >> Sub InitializeBinding()
    >> >> '**** Binding code goes here
    >> >>
    >> >> End Sub
    >> >>
    >> >> Private Sub btnSave_Click(ByVal sender As System.Object, ByVal

    e As
    >> >System.EventArgs)
    >> >> Handles btnSave.Click
    >> >>
    >> >> '*** Updating the Datasource with the help of a DataSet
    >> >> Dim tblParty As DataTable
    >> >> tblParty = dsFfsParty.Tables("Party")
    >> >> Dim drCurrent As DataRow
    >> >> drCurrent = dsFfsParty.Tables("Party").Rows.Find(TxtCode.Text)
    >> >> 'drCurrent = tblParty.Rows.Find(TxtCode.Text)
    >> >> drCurrent.BeginEdit()
    >> >> drCurrent("Phone") = txtPhone.Text
    >> >> drCurrent.EndEdit()
    >> >>
    >> >> Dim objCommandBuilder As New OleDbCommandBuilder(daFfsParty)
    >> >> daFfsParty.Update(dsFfsParty, "Party")
    >> >>
    >> >>
    >> >> End Sub
    >> >> End Class
    >> >
    >> >

    >>

    >
    >



  6. #6
    Hari Guest

    Re: Updating Oracle database


    Somebody Pleas help.!!!!!!

    Regards
    Hari.

    "Hari" <hkpillai@emirates.net.ae> wrote:
    >
    >Hi Hema,
    >
    >Thanx for the response.
    >
    >I have defined a primary key (partycode) in my table party and in the serverexplorer
    >I can see that. But I don't know why the primary key is not coming into

    the
    >dataset eventhough I use "daFfsParty.FillSchema(dsFfsParty,
    >SchemaType.Source, "Party")". I'm defining a primary key in the code below
    >is because I'm getting an error when I use find() method as suggested by
    >you. I've no idea why the primary key is not getting reflected here.
    >when I checked the selectcommand property it is showing
    >"Select * from party"
    >
    >I tried debuggin using the following code. and as soon as it comes to the
    >GetUpdateCommand it gives me the same error.
    >
    > daFfsParty.UpdateCommand = objCommandBuilder.GetUpdateCommand
    > daFfsParty.InsertCommand = objCommandBuilder.GetInsertCommand
    > daFfsParty.DeleteCommand = objCommandBuilder.GetDeleteCommand
    > sel = daFfsParty.SelectCommand.CommandText
    > upd = daFfsParty.UpdateCommand.CommandText
    > ins = daFfsParty.InsertCommand.CommandText
    > del = daFfsParty.DeleteCommand.CommandText
    >
    >Any help pls.
    >
    >Rgds
    >Hari.
    >
    >waiting for ur response.
    >
    >Rgds
    >Hari.
    >"VBDotNet Team [MS]" <vbdotnet@microsoft.com> wrote:
    >>Hi Hari,
    >>Check the updateCommand, SelectCommand and DeleteCommand properties of
    >>daFfsParty. The problem here is that the select command query does not
    >>return the primary column data for the table. Change the selectCommand

    so
    >as
    >>to return the primary column data as well. Let us know of this still does
    >>not help.
    >>
    >>Hema Nagarajan
    >>VB .NET Team
    >>
    >>--
    >>This posting is provided "AS IS" with no warranties, and confers no rights.
    >>"Hari" <hkpillai@emirates.net.ae> wrote in message
    >>news:3dfff862$1@tnews.web.devx.com...
    >>>
    >>> Hi,
    >>> Thanks a ton for the help. The problem of the "find" error is sorted

    out
    >>> but I still could not update the table. It showed the following error.
    >>>
    >>> "Dynamic SQL generation for the UpdateCommand is not supported against

    >a
    >>> SelectCommand that does not return any key column information."
    >>>
    >>> Now my code reads as follows:
    >>>
    >>> Dim tblParty As DataTable
    >>> tblParty = dsFfsParty.Tables("Party")
    >>> With tblParty
    >>> .PrimaryKey = New DataColumn() _
    >>> {.Columns("partycode")}
    >>> End With
    >>> Dim drCurrent As DataRow
    >>> drCurrent = dsFfsParty.Tables("Party").Rows.Find(TxtCode.Text)
    >>> drCurrent = tblParty.Rows.Find(TxtCode.Text)
    >>> drCurrent.BeginEdit()
    >>> drCurrent("Phone") = txtPhone.Text
    >>> drCurrent.EndEdit()
    >>>
    >>> Dim objCommandBuilder As New OleDbCommandBuilder(daFfsParty)
    >>> Try
    >>> daFfsParty.Update(dsFfsParty, "Party")
    >>> Catch effsupdate As System.Exception
    >>> Throw effsupdate
    >>> End Try
    >>>
    >>> The error comes after issuing the update command. Pls help me on this.
    >>>
    >>> Rgds
    >>> Hari.
    >>>
    >>>
    >>> "VBDotNet Team [MS]" <vbdotnet@microsoft.com> wrote:
    >>> >You need to explicity add a primary key to the dataTable object. Add

    >this
    >>> >piece of code before you do a find on the primary key.
    >>> >
    >>> > With tblParty
    >>> > .PrimaryKey = New DataColumn() _
    >>> > {.Columns("PKeyColumn")}
    >>> > End With
    >>> >
    >>> >Hope this helps.
    >>> >Hema Nagarajan
    >>> >VB .NET Team
    >>> >
    >>> >--
    >>> >This posting is provided "AS IS" with no warranties, and confers no

    >>rights.
    >>> >"Hari" <hkpillai@emirates.net.ae> wrote in message
    >>> >news:3dfec27d$1@tnews.web.devx.com...
    >>> >>
    >>> >> Hi,
    >>> >> I'm new to VB.Net. Based on the knowledge from books and sites I tried
    >>> the
    >>> >> below code to update an Oracle table from a windows forms application
    >>> in
    >>> >> VB.Net. In the below case I've a primary key defined for the "Party"

    >>table
    >>> >> and I can see it on Server Explorer but when I try to issue a "find"
    >>> >command
    >>> >> it gives me error saying that primary key not defined.
    >>> >>
    >>> >> Can anyone help me out.
    >>> >>
    >>> >> Imports System.Data
    >>> >> Imports System.Data.OleDb
    >>> >> Public Class frmParty
    >>> >> Inherits System.Windows.Forms.Form
    >>> >>
    >>> >> Friend WithEvents bmb As BindingManagerBase
    >>> >>
    >>> >> Dim dsFfsParty As New DataSet()
    >>> >> Dim cnFfs As New

    >>OleDbConnection("Provider=MSDAORA.1;Password=ffs;User
    >>> >> ID=ffs;Data Source=www")
    >>> >> Dim daFfsParty As New OleDbDataAdapter("SELECT * FROM party",

    >>cnFfs)
    >>> >> Private Sub frmParty_Load(ByVal sender As Object, ByVal e As
    >>> >System.EventArgs)
    >>> >> Handles MyBase.Load
    >>> >> CreateDataSet()
    >>> >> InitializeBinding()
    >>> >> End Sub
    >>> >>
    >>> >> Sub CreateDataSet()
    >>> >> Try
    >>> >> cnFfs.Open()
    >>> >> daFfsParty.FillSchema(dsFfsParty, SchemaType.Source,

    >>"Party")
    >>> >> daFfsParty.Fill(Me.dsFfsParty, "party")
    >>> >> Catch ffsFillException As System.Exception
    >>> >> Throw ffsFillException
    >>> >> Finally
    >>> >> cnFfs.Close()
    >>> >> End Try
    >>> >> End Sub
    >>> >>
    >>> >> Sub InitializeBinding()
    >>> >> '**** Binding code goes here
    >>> >>
    >>> >> End Sub
    >>> >>
    >>> >> Private Sub btnSave_Click(ByVal sender As System.Object, ByVal

    >e As
    >>> >System.EventArgs)
    >>> >> Handles btnSave.Click
    >>> >>
    >>> >> '*** Updating the Datasource with the help of a DataSet
    >>> >> Dim tblParty As DataTable
    >>> >> tblParty = dsFfsParty.Tables("Party")
    >>> >> Dim drCurrent As DataRow
    >>> >> drCurrent = dsFfsParty.Tables("Party").Rows.Find(TxtCode.Text)
    >>> >> 'drCurrent = tblParty.Rows.Find(TxtCode.Text)
    >>> >> drCurrent.BeginEdit()
    >>> >> drCurrent("Phone") = txtPhone.Text
    >>> >> drCurrent.EndEdit()
    >>> >>
    >>> >> Dim objCommandBuilder As New OleDbCommandBuilder(daFfsParty)
    >>> >> daFfsParty.Update(dsFfsParty, "Party")
    >>> >>
    >>> >>
    >>> >> End Sub
    >>> >> End Class
    >>> >
    >>> >
    >>>

    >>
    >>

    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center