Results 1 to 4 of 4

Thread: [2005] Display record from Table

  1. #1

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    [2005] Display record from Table

    Hello! I wonder what's the equivalent value of this vb6 code in vb.net. I would like to display specific valueto textbox from table.
    Code:
        rsStocks.Open "SELECT * FROM tblStocks WHERE Code = '" & txtCode.Text & "'", oConn, adOpenStatic, adLockOptimistic
        If rsStocks.RecordCount <> 0 Then
          txtSupply.Text = rsStocks.Fields("Quantity")
          txtDesc.Text = rsStocks.Fields("ProductDescription")
          'txtSellingPrice.Text = Format$(rsStocks.Fields("SellingPrice"), "P###,###,##0.00")    End If
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Display record from Table

    You can still use the Format function in VB.NET but you shouldn't. You should use the String.Format method, which I just demonstrated in one of your other threads. That said, Format, String.Format, StringBuilder.AppendFormat and every other method that accepts format strings accepts exactly the same format strings. MSDN has all the details on standard and custom format strings for numerical values as well as dates and times.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Display record from Table

    You'll find a good sample in one of jmc's signature links - http://www.vbforums.com/showthread.php?t=469872

  4. #4

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: [2005] Display record from Table

    i think i was not clear enough when I said I want to display specific value in my first post and for that Im sorry.

    What I should have said should be how do i achieved this kind of coding in .net
    Code:
    txtSupply.Text = rsStocks.Fields("Quantity")
    Here i am assigning whatever record the field Quantity to txtSupply.
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

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