 |
|
VB.NET ช่วยแก้โค้ดหน่อยคับ.....การแสดงข้อมูลใน Listbox VB2005 คับ |
|
 |
|
|
 |
 |
|
ผมต้องหาแสดงคำโดยดึงจากรหัส seltest มาแสดงใน listbox แต่ทำไมคำที่ต้องแสดงใน listbox2 ไปแสดงที่ listbox อื่นๆด้วยคับ
แล้วจะแก้ไขยังไงดีคับ
Code (VB.NET)
Dim strSQL1 As String = "SELECT Vocabulary1 FROM Vocabulary WHERE seltest = '1'"
da.SelectCommand = New OleDbCommand(strSQL1, cn)
Try
da.Fill(ds, "Vocabulary")
Catch ex As OleDbException
MsgBox(ex.Message)
Exit Sub
End Try
ListBox2.Items.Clear()
For Each row As DataRow In ds.Tables("Vocabulary").Rows
ListBox2.Items.Add(row("Vocabulary1").ToString) '& ControlChars.Tab & row("Word").ToString & ControlChars.Tab & row("Groups").ToString)
Next
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim strSQL2 As String = "SELECT Vocabulary1 FROM Vocabulary WHERE seltest = '2'"
da.SelectCommand = New OleDbCommand(strSQL2, cn)
Try
da.Fill(ds, "Vocabulary")
Catch ex As OleDbException
MsgBox(ex.Message)
Exit Sub
End Try
ListBox3.Items.Clear()
For Each row As DataRow In ds.Tables("Vocabulary").Rows
ListBox3.Items.Add(row("Vocabulary1").ToString) '& ControlChars.Tab & row("Word").ToString & ControlChars.Tab & row("Groups").ToString)
Next
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim strSQL3 As String = "SELECT Vocabulary1 FROM Vocabulary WHERE seltest = '3'"
da.SelectCommand = New OleDbCommand(strSQL3, cn)
Try
da.Fill(ds, "Vocabulary")
Catch ex As OleDbException
MsgBox(ex.Message)
Exit Sub
End Try
ListBox4.Items.Clear()
For Each row As DataRow In ds.Tables("Vocabulary").Rows
ListBox4.Items.Add(row("Vocabulary1").ToString) '& ControlChars.Tab & row("Word").ToString & ControlChars.Tab & row("Groups").ToString)
Next
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim strSQL4 As String = "SELECT Vocabulary1 FROM Vocabulary WHERE seltest = '4'"
da.SelectCommand = New OleDbCommand(strSQL4, cn)
Try
da.Fill(ds, "Vocabulary")
Catch ex As OleDbException
MsgBox(ex.Message)
Exit Sub
End Try
ListBox5.Items.Clear()
For Each row As DataRow In ds.Tables("Vocabulary").Rows
ListBox5.Items.Add(row("Vocabulary1").ToString) '& ControlChars.Tab & row("Word").ToString & ControlChars.Tab & row("Groups").ToString)
Next
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim strSQL5 As String = "SELECT Vocabulary1 FROM Vocabulary WHERE seltest = '5'"
da.SelectCommand = New OleDbCommand(strSQL5, cn)
Try
da.Fill(ds, "Vocabulary")
Catch ex As OleDbException
MsgBox(ex.Message)
Exit Sub
End Try
ListBox6.Items.Clear()
For Each row As DataRow In ds.Tables("Vocabulary").Rows
ListBox6.Items.Add(row("Vocabulary1").ToString) '& ControlChars.Tab & row("Word").ToString & ControlChars.Tab & row("Groups").ToString)
Next
Tag : Ms Access, VB.NET, VS 2005 (.NET 2.x)
|
|
 |
 |
 |
 |
Date :
2011-04-28 10:50:07 |
By :
pp |
View :
1626 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลอง Clear ds ก่อนน่ะครับ แล้วค่อยเปิดใหม่
ds = nothing
|
 |
 |
 |
 |
Date :
2011-04-29 16:21:11 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|