Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VB and SQL問題??

0 views
Skip to first unread message

我不高.-_-

unread,
Oct 3, 2002, 1:22:01 PM10/3/02
to
我要從VB裡的ListBox裡抓所選取的"書名"..
然後用這"書名"用SQL查詢其書的相關資料,並把資料弄到DataGrid上顯示出來.
我寫到下面這就碰到瓶頸了..

For i = 0 To List1.ListCount - 1
If List1.Selected(i)=True Then
strsql = "select * from 書籍 where 書名='" & Trim(List1.List(i)) & "'"
End If
Next i
.......................(不會寫的部份)
...............................................

Set DataGrid1.DataSource = rs

補充Private cn As New ADODB.Connection
Private rs As New ADODB.Recordset
rs已連好資料庫了

若能把查好的資料弄到別的地方show也行
拜託了高手!!!!!!!
~

--
[m [1;32m※ 來源:‧蛋捲廣場 bbs.tku.edu.tw‧[FROM: 218.187.94.173] [m

想一個人怎麼辨.-_-

unread,
Oct 3, 2002, 1:20:53 PM10/3/02
to
我要從VB裡的ListBox裡抓所選取的"書名"..
然後用這"書名"用SQL查詢其書的相關資料,並把資料弄到DataGrid上顯示出來.
我寫到下面這就碰到瓶頸了..

For i = 0 To List1.ListCount - 1
If List1.Selected(i)=True Then
strsql = "select * from 書籍 where 書名='" & Trim(List1.List(i)) & "'"
End If
Next i
.......................(不會寫的部份)
...............................................

Set DataGrid1.DataSource = rs

補充Private cn As New ADODB.Connection
Private rs As New ADODB.Recordset
rs已連好資料庫了

若能把查好的資料弄到別的地方show也行
拜託了高手!!!!!!!
~
--
[0;36m ﹍ˍ [0;36;44m ˍ◥ [0;36;40m◣◥ [0;36;44m ˍ◢ [0;36;40mˍ﹍ [1;37m泡芙機場 [m
[0;36m ﹍ˍ [0;36;44m ◢ [0;36;40m◤◢ [0;36;44m ◢ [0;36;40mˍ﹍ [0;37mOrigin:bbs.pme.nthu.edu.tw [m
[0;36m ﹍ˍ [0;36;44m◢██ [0;36;40m◣◥ [0;36;44m◢██ [0;36;40mˍ﹍ [0;36mFrom:HC218-187-94-173.2-3.pl.apol.com.tw [m

小賴

unread,
Oct 4, 2002, 12:46:44 PM10/4/02
to
==> 在 outpu...@bbs.pme.nthu.edu.tw (想一個人怎麼�的文章中提到:

> 我要從VB裡的ListBox裡抓所選取的"書名"..
> 然後用這"書名"用SQL查詢其書的相關資料,並把資料弄到DataGrid上顯示出來.
> 我寫到下面這就碰到瓶頸了..
> For i = 0 To List1.ListCount - 1
> If List1.Selected(i)=True Then
> strsql = "select * from 書籍 where 書名='" & Trim(List1.List(i)) & "'"
> End If
> Next i
> ........................(不會寫的部份)
> ................................................
> Set DataGrid1.DataSource = rs
^^^^^^^^^
你幹嘛不用 ListView 來填值
用ListView 填值比較簡單。

> 補充Private cn As New ADODB.Connection
> Private rs As New ADODB.Recordset
> rs已連好資料庫了
> 若能把查好的資料弄到別的地方show也行
> 拜託了高手!!!!!!!
> ~
--
* Origin: ★ 交通大學資訊科學系 BBS ★ <bbs.cis.nctu.edu.tw: 140.113.23.3>
0 new messages