load 1 record into a variable

hello all
i'm quite new to vb.net
i'm trying to use the online help suggestion that's supposed to load a 
specific table row into a variable:

Dim Lnrow As paraohDataSet.LoansRow
Lnrow = ParaohDataSet.Loans.FindBylID(5) (5-an existing key in my table)

trying to use it to reach any value, like using this line:
LID.Text = Lnrow.lID

causes an error : "Object reference not set to an instance of an object."

since that's exactly as it is in help, i cant find where i do wrong
please help
thanx
Erez.


Answer this question

load 1 record into a variable

  • cwg216

    paraohDataSet is a custom class Who has writen it and do you have to source


  • Todd Biggs - MSN Product Manager

    I was experiencing the same problems, so I experimented and found that the code below works. Note that I created a dataset connection to the sample Northwind Access database for the experiment.

    Dim ds As NorthwindDataSet
    ds = New NorthwindDataSet
    Dim rwNew As NorthwindDataSet.CustomersRow
    rwNew = ds.Customers.NewCustomersRow
    rwNew.CompanyName = "Test Company"
    rwNew.ContactName = "Mr. Ed"
    rwNew.CustomerID = "12345"
    ' Values for each row, etc . . .
    ds.Customers.Rows.Add(rwNew)

    When I replaced the code in my application with a structure like the above the error messages and code warnings were eliminated and the Intellisense also worked correctly.


  • DirectXer

    You don't initialize Lnrow as far as i can see. Try to use this code:



    Dim Lnrow As New paraohDataSet.LoansRow
    Lnrow = ParaohDataSet.Loans.FindBylID(5)

    LID.Text = Lnrow.lID



  • ambran

    hi

    thanx for replying

    if i try the above text you've suggested, i get the message:

    Error 1 Argument not specified for parameter 'rb' of 'Friend Sub New(rb As System.Data.DataRowBuilder)'. F:\Documents and Settings\Erez\My Documents\Visual Studio 2005\Projects\NewLoans\WindowsApplication1\frmLoanDetails.vb 29 21 WindowsApplication1

    any ideas


  • Extrarius

    I had the same problem.... I found this

    http://forums.asp.net/ShowPost.aspx PageIndex=2&PostID=1007261

    What it basically says is:

    Dim ds As yourdatasetname = New yourdatasetname

    Dim dr As DataRow = yourdatasetname.tablename.NewRow


  • Panit W.

    I can't see what the constructors are for that class. As far a i can see he wants a System.Data.DataRowBuilder, so give it to him.


    Dim Lnrow As New paraohDataSet.LoansRow( rb )
    Lnrow = ParaohDataSet.Loans.FindBylID(5)

    LID.Text = Lnrow.lID



    But you must initialize rb first.


  • Amirhossein_sh

    hello again

    if i try to istantiate rb myself the error says it shouldnt be done by the user

    can you please give me a snippet that will do the trick

    anything that will give me access to values in all fields of a chosen record

    thanx again


  • load 1 record into a variable