Public cnn As New ADODB.Connection
Public rs As New ADODB.Recordset
Public Function Connect()
Dim str As String
Connect = False
On Error GoTo ErrConn
str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB.mdb;Persist Security Info=False"
With cnn
.ConnectionString = str
.Open
End With
Connect = True
Exit Function
ErrConn:
MsgBox Err.Number & Err.Description
Exit Function
End Function
'connect.........
call connect
If rs.State = adStateOpen Then rs.Close
rs.Open "select * from [Table] where zkgcj>=60 ", cnn, adOpenStatic, ockOptimistic
Public rs As New ADODB.Recordset
Public Function Connect()
Dim str As String
Connect = False
On Error GoTo ErrConn
str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB.mdb;Persist Security Info=False"
With cnn
.ConnectionString = str
.Open
End With
Connect = True
Exit Function
ErrConn:
MsgBox Err.Number & Err.Description
Exit Function
End Function
'connect.........
call connect
If rs.State = adStateOpen Then rs.Close
rs.Open "select * from [Table] where zkgcj>=60 ", cnn, adOpenStatic, ockOptimistic
请细细指明一下,最好有注释的~~
在下是个新手,请悉心指导~
麻烦了~~
谢谢~
dim cn as new adodb.connection
dim rs as new adodb.recordset
cn.open "Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User id=Username;Password=asdasd;"
rs.open "select * from 表 where 条件" ,cn
debug.print rs.fields(0)
pulic cnn as adodb.connection
sub mian()
set cnn=new adodb.connection
With cnn
.CommandTimeout = 15
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB.mdb;Persist Security Info=False"
.CursorLocation = adUseClient
.Open
End With
end sub执行sql用adodb.recordset
public sub ExecuteSql(rst as adodb.recordset,sql as string)
set rst=cnn.execute(sql)
end sub在窗体中
private sub form_load()
dim rst as new adodb.recordset
executesql rst,"select * from tabel where fenshu>=60"
if not(rst.eof and rst.bof) then
grid.recordset =rst
end ifend sub
出了点错,我先选专业,再选老师
而后得出了上述的结果
如果老师对应的专业第一次选择不对,就提示出错
再选择的时候
Rows = 6
.CellAlignment = 2
.TextMatrix(0, 0) = "姓名"
.TextMatrix(1, 0) = "年级"
.TextMatrix(2, 0) = "系别"
.TextMatrix(3, 0) = "专业"
.TextMatrix(4, 0) = "教师"
.TextMatrix(5, 0) = "zkgcj"
这些固定值便显示不出了,请问一下这是什么原因?~
谢谢了~