請各位幫幫忙,有點急。
Private Sub Form_Load()
Dim mpath$, mlink$
mpath = App.Path ' 獲取程式所在的路徑
If Right(mpath, 1) <> "\" Then mpath = mpath + "\" ' 判斷是否為子目錄
' 以下兩行代碼可合成一句,mlink存放ConnectionString屬性的設定值
mlink = "Provider=Microsoft.Jet.OLEDB.4.0;" ' 指定提供者
mlink = mlink + "Data Source=" + mpath + "VB.mdb" ' 在資料庫檔案名前插入路徑
Adodc1.ConnectionString = mlink ' 設定連接屬性
Adodc1.CommandType = adCmdUnknown
Adodc2.ConnectionString = mlink ' 設定連接屬性
Adodc2.CommandType = adCmdUnknown ' 指定記錄集命令型別(可在設計時指定)
Adodc3.ConnectionString = mlink ' 設定連接屬性
Adodc3.CommandType = adCmdUnknown ' 指定記錄集命令型別(可在設計時指定)
Adodc4.ConnectionString = mlink ' 設定連接屬性
Adodc4.CommandType = adCmdUnknown
Adodc5.ConnectionString = mlink ' 設定連接屬性
Adodc5.CommandType = adCmdUnknown
Adodc6.ConnectionString = mlink ' 設定連接屬性
Adodc6.CommandType = adCmdUnknown
Adodc7.ConnectionString = mlink ' 設定連接屬性
Adodc7.CommandType = adCmdUnknown
Adodc8.ConnectionString = mlink ' 設定連接屬性
Adodc8.CommandType = adCmdUnknown
Adodc1.RecordSource = "select * from 詳細資料"
Adodc1.Refresh
Adodc2.RecordSource = "select 產品名稱 from 詳細資料"
Adodc2.Refresh
Adodc3.RecordSource = "select 產品名稱 from 詳細資料"
Adodc3.Refresh
Adodc8.RecordSource = "select 產品名稱 from 詳細資料"
Adodc8.Refresh
Adodc5.RecordSource = "select sum(價格*數量) as 總價 from 購買串列 where 用戶代碼= '" & Val(Label12.Caption) & "'"
Adodc5.Refresh
Adodc7.RecordSource = "select * from 顧客YSNLKI代碼表"
Adodc7.Refresh
Adodc7.Recordset.MoveLast
Label12.Caption = Adodc7.Recordset.Fields(0)
Adodc4.RecordSource = "select * from 購買串列 where 用戶代碼= '" & Val(Label12.Caption) & "'"
Adodc4.Refresh
If Adodc4.Recordset.EOF = True And Adodc4.Recordset.BOF = True Then
Commandshanchu.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Else
Commandshanchu.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
End If
End Sub
uj5u.com熱心網友回復:
欄位名匹配不上。你可以把 SQL 串貼到 Access 中除錯,它會告訴你是哪一個不對。uj5u.com熱心網友回復:
這基本上是你的SQL陳述句有問題, 你可以單獨debug.print出來看看.還有,為何要開這么多連接去打開同一個資料檔案? 你是想測驗access資料庫的并發連接性能?
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/131250.html
下一篇:求大神幫幫忙
