樹心幽徑

« 20190414解碼garmin地圖資訊檔(gmapsupp_Taiwan_moi_zh_camp.img) | Main | 20190517用c語言程式kml2gpx.c將20140829南勢溪源頭拳頭母山松蘿湖.kml轉為gpx檔 »

20190418用VB6連線MS-SQL Server 2000的ilvssell資料庫,讀出new_goods資料表的所有資料錄內容
2019/04/18,12:41

(一) setup

alt

 

(二) code1

Public cn As New ADODB.Connection
Public rs As New ADODB.Recordset



Private Sub Command1_Click()
Form1.Cls
st = "Provider=SQLOLEDB; Perslist Security Info=False; User ID=cat; Pwd=cat123; Initial Catalog=ilvssell; Data Source=10.1.1.9"
cn.Open st

MsgBox "連線成功" & st
sqlstr = "select gdsno, gdsname, price_sell, stock_qty from new_goods"
rs.Open sqlstr, cn, , , adCmdText
c = 0
While Not rs.EOF
    c = c + 1
    x = c & ":" & rs("gdsno") & ":" & rs("gdsname") & ":" & rs("price_sell") & ":" & rs("stock_qty")
    List1.AddItem x
    Combo1.AddItem x
   
    Print x
    rs.MoveNext
Wend
rs.Close
  
cn.Close

End Sub

 

(二b) code2

Private Sub Command2_Click()

Set cn = CreateObject("ADODB.Connection")

cn.ConnectionString = "Provider=SQLOLEDB; Perslist Security Info=False; User ID=cat2; Pwd=abc123; Initial Catalog=ilvssell; Data Source=10.1.1.9"cn.OpenPrint "connection ok!"

Set rs = CreateObject("ADODB.Recordset")

sqlstr = "select gdsno, gdsname, price_sell, stock_qty from new_goods"

rs.Open sqlstr, cn, , , adCmdText

c = 0

While Not rs.EOF   

c = c + 1   

Print c & ":" & rs("gdsname") & ":" & rs("stock_qty")   

rs.MoveNext

Wend

rs.Close

cn.Close
End Sub

 

迴響

 
Accessible and Valid XHTML 1.0 Strict and CSS Powered by LifeType