Results 1 to 2 of 2

Thread: Object reference not set to an instance of an object.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2002
    Location
    Milton Keynes UK
    Posts
    27

    Object reference not set to an instance of an object.

    Can anyone help - I am trying to add a record (with no success!) The following code comes up with the error message Object reference not set to an instance of an object.at the line marked (***). Must be a simple reason but I can't work it out...

    Cheers

    John

    Private Sub btnAddUser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddUser.Click

    OleDbDataAdapter1.Fill(DsAllProfile1, "tblProfile")
    Dim objTable As DataTable
    Dim drRows As DataRowCollection
    Dim objNewRow As DataRow

    objTable = DsAllProfile1.Tables("tblProfile")
    drRows = objTable.Rows

    (***)objNewRow("Default") = CBool("1")
    objNewRow("ProfileWeight") = 233
    objNewRow("ProfileName") = "Pablo"
    objNewRow("ProfileDOB") = "23/02/71)"
    objNewRow("ProfileSex") = CBool("1")

    drRows.Add(objNewRow)



    End Sub

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    VB Code:
    1. Private Sub btnAddUser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddUser.Click
    2.  
    3. OleDbDataAdapter1.Fill(DsAllProfile1, "tblProfile")
    4. Dim objTable As DataTable=DsAllProfile1.Tables("tblProfile")
    5. Dim objNewRow As DataRow=ObjTable.NewRow
    6.  
    7. objNewRow("Default") = CBool("1")
    8. objNewRow("ProfileWeight") = 233
    9. objNewRow("ProfileName") = "Pablo"
    10. objNewRow("ProfileDOB") = "23/02/71)"
    11. objNewRow("ProfileSex") = CBool("1")
    12.  
    13. objTable.Rows.Add(objNewRow)
    14.  
    15. End Sub

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