我以前用DATAENVIRONMENT
现在想学一下用ADO代码通过ODBC连接SQL 7.0 数据库
或直接用ADO代码连接到SQL 7.0数据库
连接时后请对数据库操作一下比如SELECT 等
连接结束后请断开与数据库的连接.
请写出详细代码和说明.
谢谢!
现在想学一下用ADO代码通过ODBC连接SQL 7.0 数据库
或直接用ADO代码连接到SQL 7.0数据库
连接时后请对数据库操作一下比如SELECT 等
连接结束后请断开与数据库的连接.
请写出详细代码和说明.
谢谢!
Dim Rs As New ADODB.Recordset
CN.ConnectionString = "Provider=SQLOLEDB.1;Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=wktrade;Data Source=net5"
CN.Open
Rs.CursorLocation = adUseClient
Rs.Open "select * from employees", CN, adOpenDynamic, adLockBatchOptimistic
Set DataGrid1.DataSource = Rs
CN.CLOSE
RS.CLOSE
SET CN=Nothing
set Rs=nothing
Dim Rs As New ADODB.Recordset
CN.ConnectionString = "Provider=sqloledb;Data Source=pmserver;Initial Catalog=northwind;User Id=sa;Password=sa;"
CN.Open
Rs.CursorLocation = adUseClient
Rs.Open "select * from employees", CN, adOpenDynamic, adLockBatchOptimistic
Set DataGrid1.DataSource = Rs
Dim strConnection as String
Dim strSQL as StringstrConnection ="Provider=sqloledb.1;Persist Security Info=False;User ID=sa;Initial Catalog=nbkyz;Data Source=192.168.0.1;Password=123"
oConnect.Open strConnection strSQL="SELECT function_id FROM user_function_aid WHERE user_id='centertest' AND function_id='QueryBusInfo'"oConnect.Execute strSQLoConnect.Close
Persist Security Info=true这是什么意思?还有别的参数吗?
Rs.CursorLocation = adUseClient这是什么意思?还有别的参数吗?
object.Properties("Persist Security Info") [= value]Parts
objectExpression that evaluates to an object in the Applies To list.valueBoolean that specifies whether the data source can persist authentication information, as specified in Settings.Settings
Value Description
True The data source object can persist sensitive authentication information such as a password along with other authentication information.
False The data source object cannot persist sensitive authentication information.