Results 1 to 13 of 13

Thread: Read specific record in database ?[Resolved]

  1. #1

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Read specific record in database ?[Resolved]

    How ?

    Thanks for any help !
    Last edited by Pirate; Apr 1st, 2003 at 03:57 PM.

  2. #2

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    No databinding at all .

  3. #3
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    What you mean by specific record? I mean how you specify that record?

    If you want to read the record number 10, column number 2 for example then one way would be
    VB Code:
    1. mydata=myDataset.mytable.Row(9)(1) 'Zero based index
    2. 'or
    3. mydata=myDataset.myTable.Rows.Item(9)(1)

    If you want to read a record based on a primary key or value of a filed, then that would be another story
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  4. #4

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Yes Lunatic3 , I need to show the whole record after I provide some info .Meaning , show all data based on specific given value .

    Got it ?

    Thank you

  5. #5
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    That is what a Select SQL statement is for Pirate.

    Select * From table Where something = somthing
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  6. #6

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Well , I did tried that . See this...
    but I want to show all related fields . How ?
    VB Code:
    1. Public Overloads Shared Function speificRec(ByVal colum As String, ByVal SearchText As String, ByVal lstbox As ListBox)
    2.                 Dim sql As String = "Select C_URL FROM MyTab"
    3.  
    4.                 Dim da As New OleDbDataAdapter(sql, MyConnection)
    5.                 Static ds As DataSet
    6.                 If ds Is Nothing Then
    7.                     'if not filled yet fill it
    8.                     ds = New DataSet()
    9.                     'fill dataset
    10.                     OpenDB.OpenDB()
    11.  
    12.                     da.Fill(ds, "MyTab")
    13.                     CloseDB.CloseDB()
    14.                     da.Dispose()
    15.                 End If
    16.  
    17.                 Try
    18.                     Dim dv As New DataView(ds.Tables("MyTab"), "" & colum & " Like'" & SearchText & "%'", colum, DataViewRowState.CurrentRows)
    19.  
    20.  
    21.                     lstbox.DataSource = dv
    22.                     lstbox.DisplayMember = colum
    23.                 Catch x As Exception
    24.                     MsgBox(x.Message)
    25.                 End Try
    26.             End Function
    27.  
    28.         End Class

  7. #7
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Pirate, you really need to be more clear. I have no clue what you are trying to figure out.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  8. #8
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    you mean all of the values of a specific row?

    Then
    VB Code:
    1. Dim allvalues as Array
    2. allvalues=myDs.myDatatable.Rows(desiredrowindex).ItemArray
    3.  
    4. 'or for dataviews
    5.  
    6. allvalues=myDV.Item(desiedrowindex).Row.ItemArray
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  9. #9

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    yeah yeah Lunatic3 . That's it . So how can I do then ?
    Sorry guys if I confused you

  10. #10

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Lunatic3
    you mean all of the values of a specific row?

    Then
    VB Code:
    1. Dim allvalues as Array
    2. allvalues=myDs.myDatatable.Rows(desiredrowindex).ItemArray
    3.  
    4. 'or for dataviews
    5.  
    6. allvalues=myDV.Item(desiedrowindex).Row.ItemArray
    Sorry Lunatic3 , Do you mean this ? I haven't tried it yet!

  11. #11
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Yes, then you can play with allvalues array.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  12. #12

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Ok , I will give it a shot and tell you what happened .
    Thanks Lunatic3 .

  13. #13

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Lunatic3 , I used another way around to achieve what I need . I customized the SQL Stat. to load all records for specific table and then used datarow object assigned to label or textbox or whatever .
    It's solved now .

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