تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
مشكلة عند عرض البيانات داخل داتا قرايد فيو
#1
Photo 
استعملت هذا الكود لعرض البيانات وكانت النتيجة غريبة جدا  
 Dim sql As String = " Select (storedetail.num) as x1 ,(storedetail.datea) as x2,(storedetail.q3) as x3  ,(storedetail.q4) as x4 ,(storedetail.price) as x5,mowared,(acounts.acounname) as x6,(storedetail.type)as x7 ,(storedetail.mostand)as x8   From storedetail INNER JOIN acounts ON storedetail.mowared=acounts.acountnum  where storedetail.active =1 and storedetail.itemnum ='" & TextBox1.Text & "' order by storedetail.num ,storedetail.datea"
      

        Dim sqlcommand As New SqlCommand(sql, Con)
        Dim sqladapter = New SqlDataAdapter(sqlcommand)
        Dim dt As New DataTable
        dt.Clear()
        sqladapter.Fill(dt)
        If dt.Rows.Count > 0 Then
            DataGridView1.Rows.Clear()
            For i = 0 To dt.Rows.Count - 1
                DataGridView1.Rows.Add()
                DataGridView1.Rows(DataGridView1.Rows.Count - 1).Cells(0).Value = dt.Rows(i).Item("x1")
                DataGridView1.Rows(DataGridView1.Rows.Count - 1).Cells(1).Value = dt.Rows(i).Item("x2")
                DataGridView1.Rows(DataGridView1.Rows.Count - 1).Cells(2).Value = dt.Rows(i).Item("x3")
                DataGridView1.Rows(DataGridView1.Rows.Count - 1).Cells(3).Value = dt.Rows(i).Item("x4")
                '     DataGridView1.Rows(DataGridView1.Rows.Count - 1).Cells(4).Value = dt.Rows(i).Item("x6")
                DataGridView1.Rows(DataGridView1.Rows.Count - 1).Cells(5).Value = dt.Rows(i).Item("x5")
                ' DataGridView1.Rows(DataGridView1.Rows.Count - 1).Cells(6).Value = dt.Rows(i).Item("x9")
                DataGridView1.Rows(DataGridView1.Rows.Count - 1).Cells(7).Value = dt.Rows(i).Item("x6")

                DataGridView1.Rows(DataGridView1.Rows.Count - 1).Cells(8).Value = dt.Rows(i).Item("x7")
                DataGridView1.Rows(DataGridView1.Rows.Count - 1).Cells(9).Value = dt.Rows(i).Item("x8")

            Next
        Else
            MessageBox.Show("nothing")
            DataGridView1.Rows.Clear()

        End If
وكانت النتيجة عند التنفيذ كما يلي

 فقط يتم تعبئة السطر الاخير من الاداة والباقي فاضى
الرد }}}
تم الشكر بواسطة:
#2
احذف cunt -1   وضيف مكانها 
متغير حلقة التكرار  i
صلى الله على نبينا محمد
اخيكم / محمود صالح
  قال الزهري رحمه الله  
 مــا عُـــبـِد الله بشئ أفضل من العلم 
الرد }}}
تم الشكر بواسطة:



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


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم