trimsql
❶ VB如何設置ADODC連接sql字元串使用變數
應該可以吧,不過變數不能這么的表示,要加單引號及雙引號和& 字元,試試改成user id = '" & trim(ip.text)&"',其餘的參照
❷ vb中連接SQL查詢語句代碼
『模塊中的代碼
Public Function connectstr() As String
sqlpath = App.Path & "\資料庫.mdb"
connectstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sqlpath & "" 『access資料庫
End Function
Public Function runselect(ByVal sqlm As String) As ADODB.Recordset '返回記錄集
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
On Error GoTo run_error
Set cn = New ADODB.Connection
cn.Open connectstr()
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.LockType = adLockOptimistic
rs.Open Trim(sqlm), cn, adOpenDynamic
Set runselect = rs
Set rs = Nothing
Set cn = Nothing
run_error:
MsgBox Err.Description
End Function
』窗體中的代碼.................
Private Sub Combo1_Change()
Dim mrc As New ADODB.Recordset
Set mrc = runselect("select * from 表 where 欄位='" & Trim(Combo1.Text) & "'")
Set DataGrid1.DataSource = mrc '顯示在 datagrid 中
End Sub
❸ ORACLE想通過取得幾次執行查詢語句的執行時間計算得到平均值,應該如何寫SQL語句呢
貌似沒有好辦法啊
但有個笨方法
select sysdate from al;
查詢語句1;
查詢語句2;
查詢語句3;
select sysdate from al;
開始執行查詢語句前的sysdate和執行後的sysdate求差,得到的秒數除以語句條數