Results 1 to 4 of 4

Thread: I have an error I can't seem to debug..

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2004
    Location
    Philippines
    Posts
    125

    Exclamation I have an error I can't seem to debug..

    hi everyone...

    What do you think this error means? Or how can I solve this error?

    Data cannot be read from a Datagrid which is not bound to a DataTable.

    This only happens when I try to bind the two fields in my database table QuoteDoc.

    FYI, my table QuoteDoc has a relation with another table QuoteTran. If my explanation is not that clear, please feel free to ask...

    I will greatly appreciate your help!
    thanks!

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Are you trying to bind two relational tables to a datagrid ?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2004
    Location
    Philippines
    Posts
    125
    thanks for replying pirate...

    yes and I already have. To make it clearer, here's my code...

    Private Sub btnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFind.Click

    Try
    ds.Clear()
    daDoc.Fill(ds, "QuoteDoc")
    daTran.Fill(ds, "QuoteTran")
    ds.Relations.Add("DocTran", ds.Tables!QuoteDoc.Columns!Reference, ds.Tables!QuoteTran.Columns!Reference)

    txtRef.DataBindings.Add("Text", ds.Tables!QuoteDoc, "Reference")
    dtpQuote.DataBindings.Add("Text", ds.Tables!QuoteDoc, "QuoteDate")
    cmbTerms.DataBindings.Add("Text", ds.Tables!QuoteDoc, "TermsID")
    txtCustomer.DataBindings.Add("Text", ds.Tables!QuoteDoc, "CustomerID")
    txtdiscount.DataBindings.Add("Text", ds.Tables!QuoteDoc, "Discount") -->THIS PRODUCES THE ERROR
    txtspldiscount.DataBindings.Add("Text", ds.Tables!QuoteDoc, "SplDiscount") --> AND THIS ONE TOO
    txtgrand.DataBindings.Add("Text", ds.Tables!QuoteDoc, "QuoteTotal")
    DataGrid1.DataSource = ds.Tables!QuoteDoc
    DataGrid1.DataMember = "DocTran"
    cm = CType(Me.BindingContext(ds.Tables!QuoteDoc), CurrencyManager)
    Catch ex As Exception
    MsgBox(ex.Message, MsgBoxStyle.OKOnly, "Error")
    End Try
    btnFirst.Enabled = True
    btnnext.Enabled = True
    btnprevious.Enabled = True
    btnnext.Enabled = True
    btnlast.Enabled = True

    End Sub

    when i included these two lines to my codes, it produces that error. i can't understand why because i used the same codes like those of the others. please help me pirate...

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I'm sorry , I never worked with complex binding. Just hate binding. Here's an
    example that might help .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width