-
Updating Oracle table using Dataset (vb.net) .Help me Plssssssss.
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. When issuing the update command I get the following error:
"Dynamic SQL generation for the UpdateCommand is not supported against a
SelectCommand that does not return any key column information."
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. 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
Can anyone help me out.
My full code looks like below :
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")
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
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks