19-01-18, 07:29 AM
(آخر تعديل لهذه المشاركة : 19-01-18, 07:30 AM {2} بواسطة nooralcown.)
استعملت هذا الكود لعرض البيانات وكانت النتيجة غريبة جدا
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
وكانت النتيجة عند التنفيذ كما يلي
فقط يتم تعبئة السطر الاخير من الاداة والباقي فاضى
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
وكانت النتيجة عند التنفيذ كما يلي
فقط يتم تعبئة السطر الاخير من الاداة والباقي فاضى