using ado:First. Uses menu 'Project | Reference' to add Microsoft Active Data Object Library reference.Second.dim cnn as new ADODB.Connection
dim rst as new ADODB.Recordset Dim UserName As String
Dim Password As String
Dim ServerName As String
Dim DBName As String
UserName = "sa" 'Login User here
Password = "" 'login password here
ServerName = "YourServerName" 'the name of your server that running SQL Server here
DBName = "Northwind" 'specifing the database here
' Set connection properties.
cn.ConnectionTimeout = 25 ' Set the time out.
cn.Provider = "sqloledb" ' Specify the OLE DB provider.
cn.Properties("Data Source").Value = ServerName ' Set SQLOLEDB connection properties.
cn.Properties("Initial Catalog").Value = DBName ' Set SQLOLEDB connection properties.
cn.Properties("Integrated Security").Value = "SSPI" ' Set SQLOLEDB connection properties.
' Open the database.
cn.Open
' Open the Recordset.
rs.Open "select * from Employees", cn, adOpenKeyset, adLockPessimistic'do the work code here....
dim rst as new ADODB.Recordset Dim UserName As String
Dim Password As String
Dim ServerName As String
Dim DBName As String
UserName = "sa" 'Login User here
Password = "" 'login password here
ServerName = "YourServerName" 'the name of your server that running SQL Server here
DBName = "Northwind" 'specifing the database here
' Set connection properties.
cn.ConnectionTimeout = 25 ' Set the time out.
cn.Provider = "sqloledb" ' Specify the OLE DB provider.
cn.Properties("Data Source").Value = ServerName ' Set SQLOLEDB connection properties.
cn.Properties("Initial Catalog").Value = DBName ' Set SQLOLEDB connection properties.
cn.Properties("Integrated Security").Value = "SSPI" ' Set SQLOLEDB connection properties.
' Open the database.
cn.Open
' Open the Recordset.
rs.Open "select * from Employees", cn, adOpenKeyset, adLockPessimistic'do the work code here....
解决方案 »
- 【挑战】VB 获取 网页flash中的文字
- 写一个读取textbox每一行的函数
- 哪位能解释http://218.11.76.25/dcount.asp?ssnum=11224348在服务器端的存放路径
- 【问】如何让电脑进入休眠状态?
- 各位高手:我做了两个ActiveX控件,程序运行时正常,可结束后出现警告!求求各位帮帮忙。
- 继羞于启齿!
- 我的Api 函数版本比较低,到哪下载
- MDAC_TYPE???
- 远程接入,什么是远程接入系统?
- 请问我如何在代码里面控制vb对数据(数据库中的)的保存,因为一般是自动保存,我想手动控制他
- 请教大虾一个关VB的tabstrip控件的问题
- vb60+sp4 sybae11 用ado连接后....
dim rst as new ADODB.Recordsetcnn.open "driver={sql server};server=服务器名;uid=你的用户名;pwd=你的密码;database=你要查的数据库"
rst.open 你的sql语句,cnn,1,1