تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
سؤال في جملة select top()
#2
PHP كود :
 Dim dbpath As String IO.Path.GetDirectoryName(Application.ExecutablePath) & "\db.accdb"
 
   Dim str As String "provider=microsoft.ace.oledb.12.0;data source=" dbpath
    Private Sub Button1_Click
(sender As ObjectAs EventArgsHandles Button1.Click
        Dim con 
As New OleDb.OleDbConnection(str)
 
       Dim cm As New OleDb.OleDbCommand(""con)
 
       cm.CommandText "select Top 2 *   from tb1 order by tid desc"
 
       Dim dt As New DataTable
        If con
.State ConnectionState.Closed Then con.Open()
 
       dt.Load(cm.ExecuteReader)
 
       If dt.Rows.Count 0 Then
            Dim rowindex 
As Integer dt.Rows.Count 1
            TextBox1
.Text dt.Rows(rowindex).Item(1) & " - " dt.Rows(rowindex).Item(2)
 
       End If
 
       dt.Clear()
 
       If con.State ConnectionState.Open Then con.Close()
 
   End Sub 

عدل ما يلزم ليعمل معك


طيب ما رايك بهذا؟

PHP كود :
​ 
PHP كود :
 Dim dbpath As String IO.Path.GetDirectoryName(Application.ExecutablePath) & "\db.accdb"
 
   Dim str As String "provider=microsoft.ace.oledb.12.0;data source=" dbpath
    Private Sub Button2_Click
(sender As ObjectAs EventArgsHandles Button2.Click
        TextBox1
.Clear()
 
       Dim con As New OleDb.OleDbConnection(str)
 
       Dim cm As New OleDb.OleDbCommand(""con)
 
       cm.CommandText "select top 1 *   from tb1 where degree<(select top 1 degree from tb1 order by tid desc) order by tid desc"
 
       Dim dr As OleDb.OleDbDataReader
        If con
.State ConnectionState.Closed Then con.Open()
 
       dr cm.ExecuteReader
        If dr
.HasRows Then
            If dr
.Read Then
                TextBox1
.Text dr(1) & " - " dr(2)
 
           End If
 
       End If
 
       If con.State ConnectionState.Open Then con.Close()
 
       dr.Close() 
اللهم إني أعوذ بك من غلبة الدين وغلبة العدو، اللهم إني أعوذ بك من جهد البلاء ومن درك الشقاء ومن سوء القضاء ومن شماتة الأعداء
اللهم اغفر لي خطيئتي وجهلي، وإسرافي في أمري وما أنت أعلم به مني، اللهم اغفر لي ما قدمت وما أخرت، وما أسررت وما أعلنت وما أنت أعلم به مني، أنت المقدم وأنت المؤخر وأنت على كل شيء قدير
الرد }}}
تم الشكر بواسطة:


الردود في هذا الموضوع
سؤال في جملة select top() - بواسطة bassant - 08-05-22, 03:30 PM
RE: سؤال في جملة select top() - بواسطة سعود - 24-05-22, 06:52 PM


التنقل السريع :


يقوم بقرائة الموضوع: