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求差,得到的秒数除以语句条数