| 发表于:2007-06-14 15:54:286楼 得分:0 |
dim cnn as new adodb.recordset dim rs as new adodb.recordset dim strcnn as string, strsql as string on error goto exithandle strcnn= "driver={sql server};server= " & @servername & ";uid= " & @userid & ";pwd= " & @password & ";database= " & @database cnn.cursorlocation = aduseclient cnn.open strcnn strsql=.... rs.open strsql, cnn, adopenforwardonly, adlockreadonly '如果只是浏览的话 set rs.activeconnection = nothing set datagrid1.datasource = rs exithandle: if err.number <> 0 then msgbox err.number & ": " & err.description if rs.state = adstateopen then rs.close set rs = nothing end if if cnn.state = adstateopen then cnn.close set cnn = nothing | | |
|