Results 1 to 8 of 8

Thread: loopinh

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2004
    Posts
    5

    Question loopinh

    hello

    can anyone help me how to loop? this is the code
    dim itemcode as char

    Dim conbackview As New OdbcCommand("select item_code from warehouse_mst where jpn =' " & qjpn2 & " ' ", connbackview)
    Dim drbackview As OdbcDataReader = conbackview.ExecuteReader(CommandBehavior.Default)

    Do While drbackview.Read

    itemcode = drbackview.Item("item_code")
    MsgBox(itemcode)

    Loop

    'the connbackview is my connection with my database but it will not disply the itemcode..
    hope u can help me
    r

  2. #2
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416
    no need to put do

    while drbackview.Read
    'do your stuff
    end while

  3. #3
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    VB Code:
    1. Dim Conn As OleDbConnection
    2. Dim Cmd As OleDbCommand
    3. Dim reader As OleDbReader
    4. Dim itemCode As String
    5.  
    6. Conn = New OleDbConnection("Your database ConnectionString")
    7. Cmd = New OleDbCommand("SELECT item_code FROM warehouse_mst WHERE jpn ='" & qjpn2 & "'", Conn)
    8.  
    9. Try
    10.    Conn.Open()
    11.    reader = Cmd.ExecuteScalar()
    12.  
    13.    If reader.HasRows()
    14.       itemcode = reader("item_code").ToString()
    15.    End If
    16.  
    17.    MsgBox(itemcode)
    18.  
    19.    reader.Close()
    20. Catch ex As Exception
    21.    MsgBox(ex.Message())
    22. Finally
    23.    Conn.Close()
    24. End Try
    Last edited by Memnoch1207; Oct 15th, 2004 at 05:52 PM.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2004
    Posts
    5

    Question loss

    helo

    id try it but i did not work..

    im using odbc driver
    r

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2004
    Posts
    5

    Question loss

    helo

    id try it but i did not work..

    im using odbc driver
    r

  6. #6

    Thread Starter
    New Member
    Join Date
    Oct 2004
    Posts
    5

    Question

    table format :

    item_code jpn

    000001 2222
    000002 2222

    then i want to get the item_code if the txtjpn s equal to the jpn from the table

    how should i do that?


    thanks
    r

  7. #7
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    Why don't you just use OLEDB, it's faster?
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  8. #8
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    if you are using a datareader you need to call the read method to get the first record

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