主题:宝宝帮我看一下呀!!
kskksk
[专家分:620] 发布于 2005-11-30 16:24:00
Dim tablename As String = "couset"
Dim strsql As String = "selec 课程名 from couset where 专业='" & ComboBox1.Text & "'"
ExecuteSQL(searchSQL, tablename)
Dim newrow As DataRow
Dim i As Int16
For i = 1 To [color=FF0000]newrow.count-1[/color]
Next
End Sub
中间的代码怎么写呀??中间的意思是i的值从1到记录的总条数-1,这里我不会。
然后就是for.....next之间的代码了。怎么把记录从数据库写到listbox2中。能给我具体点的代码吗??谢谢大虾了1
回复列表 (共6个回复)
沙发
andy5337 [专家分:760] 发布于 2005-12-01 12:45:00
中间的意思是i的值从1到记录的总条数-1?
什么意思看不懂.
在解释一下。
板凳
kskksk [专家分:620] 发布于 2005-12-01 13:17:00
怎么把记录从数据库写到listbox2中,就是说把这个for ..next语句写完整。
这句可以不用理他了。“中间的意思是i的值从1到记录的总条数-1“
3 楼
huyun2008 [专家分:90] 发布于 2005-12-01 13:23:00
ListBox2.Items.Clear()
Dim stkinfo As New stuInfo
stkinfo = GetInfo(0)
Dim j As Integer
Dim Item(6) As String
For j = 0 To stkinfo.count - 1
stkinfo = GetInfo(j)
Item(0) = stkinfo.xuehao
Item(1) = stkinfo.xingming
Item(2) = stkinfo.yingyu
Item(3) = stkinfo.dianzhi
Item(4) = stkinfo.vc
Item(5) = stkinfo.shuju
ListBox2.Items.Insert(j, New ListViewItem(Item))
Next j
4 楼
宝宝啊呜 [专家分:990] 发布于 2005-12-01 13:36:00
dim reader as sqldatareader
dim cmd as new sqlcommand(strsql,conn)
............
reader=cmd.executeReader
Do While reader.Read
For i = 0 To reader.FieldCount - 1
ListBox1.Items.Add(reader.Item(i) & vbNewLine)
Next
Loop
试下看看
5 楼
huyun2008 [专家分:90] 发布于 2005-12-01 13:40:00
Public Function GetInfo(ByVal index As Integer)
Dim ds As New DataSet
ds.Clear()
sqlstr = "SELECT * FROM student"
ds = GetDataFromDB(sqlstr)
Dim stkinfo As New stuInfo
Try
If Not ds Is Nothing Then '''''用这句话就可以了 ?????为什么????
'If ds.Tables(0).Rows.Count > 0 Then'''''用这句话当帐号不存在时就会有异常?????为什么????
stkinfo.xuehao = ds.Tables(0).Rows(index)("xuehao")
stkinfo.xingming = ds.Tables(0).Rows(index)("xingming")
stkinfo.yingyu = ds.Tables(0).Rows(index)("yingyu")
stkinfo.dianzhi = ds.Tables(0).Rows(index)("dianzhi")
stkinfo.vc = ds.Tables(0).Rows(index)("vc")
stkinfo.shuju = ds.Tables(0).Rows(index)("shuju")
stkinfo.pass = ds.Tables(0).Rows(index)("pass")
stkinfo.ess = True
stkinfo.count = ds.Tables(0).Rows.Count
'Return stkinfo
' ElseIf ds Is Nothing Then
Else
stkinfo.ess = False ''''当帐号不存在就显示为false
End If
Catch ex As Exception
MessageBox.Show("有异常!!", "提示消息")
End Try
Return stkinfo
End Function
6 楼
kskksk [专家分:620] 发布于 2005-12-01 19:13:00
谢谢宝哥,我太爱你了。。
我来回复