HELP!! vb.net and oracle

parv_spn

Member
Joined
Feb 9, 2006
Messages
19
Programming Experience
1-3
Hi everyone,
Please help me!

I've started database programming in vb.net.
I'm using visual studio 2005 and oracle 9i as a back-end.

I'm getting some run-time exceptions,when I'm trying to bind data to a textbox on the following statement: -

Me.txtLastName.DataBindings.Add("Text",Me.objDataV iew, "authors.au_lname")

and the exception I'm getting is:-
ArgumentException was unhandled!

Child list for field authors cannot be created.

I know its a silly problem,but I can't seem to solve it.
Please help me guys.:(

Thanks in advance,
parv_spn

 
Sorry, wasn't sure about the dataview. I bind to datasets so it would look like:
Me.txtLastName.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.DataSet11, "authors.au_lname"))
 
DavidT_macktool said:
Sorry, wasn't sure about the dataview. I bind to datasets so it would look like:
Me.txtLastName.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.DataSet11, "authors.au_lname"))

Yes, this is working now. I'm not getting any exceptions now but no data is appearing on the forms now.I'll try to look after that.
Thanks for your help anyways.
How did it work by the way??
 
This is my whole code to be precise:-->

Imports System.Data
Imports System.Data.OracleClient
______________________________________________________________________

Public Class Form1

Dim connString As New String("Data Source=Parv;Persist Security Info=True;User ID=pubs1;Password=pubs1;Unicode=True")
Dim conn As New OracleConnection(connString)
Dim cmd As OracleCommand = conn.CreateCommand()
Dim objDataAdapter As New OracleDataAdapter(cmd)
Dim objDataSet As pubs1DataSet
Dim objDataView As DataView
Dim objCurrencyManager As CurrencyManager

______________________________________________________________________
Private Sub FillDataSetandView()

objDataSet =
New pubs1DataSet()
objDataAdapter.Fill(objDataSet, "authors_t")
objDataView =
New DataView(objDataSet.Tables("authors"))
objCurrencyManager =
CType(Me.BindingContext(objDataView), CurrencyManager)

End Sub
___________________________________________________________________________________
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

cmd.CommandText = "SELECT authors.au_id,authors.au_lname,authors.au_fname,titles.title,titles.price FROM authors,titles,titleauthor WHERE authors.au_id = titleauthor.au_id AND titles.title_id = titleauthor.title_id"

FillDataSetandView()

cboField.Items.Add(
"Last Name")
cboField.Items.Add(
"First Name")
cboField.Items.Add(
"Book Title")
cboField.Items.Add(
"Price")
cboField.SelectedIndex = 0

BindFields()
ShowPosition()

End Sub
___________________________________________________________________________________

Private Sub BindFields()

txtLastName.DataBindings.Clear()
txtFirstName.DataBindings.Clear()
txtBookTitle.DataBindings.Clear()
txtPrice.DataBindings.Clear()


Me.txtLastName.DataBindings.Add(New Windows.Forms.Binding("Text", Me.objDataSet, "authors.au_lname"))
Me.txtFirstName.DataBindings.Add(New Windows.Forms.Binding("Text", Me.objDataSet, "authors.au_fname"))
Me.txtBookTitle.DataBindings.Add(New Windows.Forms.Binding("Text", Me.objDataSet, "titles.title"))
Me.txtPrice.DataBindings.Add(New Windows.Forms.Binding("Text", Me.objDataSet, "titles.price"))
StatusStrip1.Text = "Ready"

End Sub
____________________________________________________________________________________

Private Sub ShowPosition()

txtRecordPosition.Text = objCurrencyManager.Position + 1 &
" of " & objCurrencyManager.Count()
End Sub
Private Sub btnMoveFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMoveFirst.Click
objCurrencyManager.Position = 0
ShowPosition()

End Sub

___________________________________________________________________________________
Private Sub btnMovePrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMovePrevious.Click

objCurrencyManager.Position -= 1
ShowPosition()

End Sub
___________________________________________________________________________________

Private Sub txtMoveNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtMoveNext.Click

objCurrencyManager.Position += 1
ShowPosition()

End Sub
___________________________________________________________________________________

Private Sub btnMoveLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMoveLast.Click

objCurrencyManager.Position = objCurrencyManager.Count - 1
ShowPosition()

End Sub
_____________________________________________________________________________________

Private Sub btnPerformSort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPerformSort.Click

Select Case cboField.SelectedIndex

Case 0 'Last Name
objDataView.Sort = "au_lname"
Case 1 'First Name
objDataView.Sort = "au_fname"
Case 2 'Book Title
objDataView.Sort = "title"
Case 3 'Price
objDataView.Sort = "price"


End Select

btnMoveFirst_Click(
Nothing, Nothing)
StatusStrip1.Text =
"Records Sorted"

End Sub
___________________________________________________________________________________

End
Class
_____________________________________________________________________________________
 
for the bindings to work u have to make a binding source and assing the binding source not the dataset

Dim bindingSourcetxt As BindingSource
If objDataSet IsNot Nothing Then
bindingSourcetxt = New BindingSource(objDataSet, "authors")

End If
Me.txtLastName.DataBindings.Add(New Windows.Forms.Binding("Text", bindingSourcetxt, "au_lname"))

hope it helps
 
larris said:
for the bindings to work u have to make a binding source and assing the binding source not the dataset

Dim bindingSourcetxt As BindingSource
If objDataSet IsNot Nothing Then
bindingSourcetxt = New BindingSource(objDataSet, "authors")

End If
Me.txtLastName.DataBindings.Add(New Windows.Forms.Binding("Text", bindingSourcetxt, "au_lname"))

hope it helps

Thank you very much mate. Its working now...:) Just one more correction..' End If ' will be after Me.txtLastName.... statement..
cheers!!
 
Back
Top