ADO的OPEN语句用到的用户名和密码在ACCESS中如何设置?

一脚滑倒 2001-12-05 09:22:36
另有一个问题:请大家说说三种连接数据库哪个比较好?有什么差别?
...全文
62 3 打赏 收藏 举报
写回复
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
mmzxg 2001-12-05
  • 打赏
  • 举报
回复

根据需要
sonicdater 2001-12-05
  • 打赏
  • 举报
回复
This example uses the Open and Close methods on both Recordset and Connection objects that have been opened.

'BeginOpenVB

'To integrate this code
'replace the data source and initial catalog values
'in the connection string

Public Sub OpenX()

Dim Cnxn As ADODB.Connection
Dim rstEmployees As ADODB.Recordset
Dim strCnxn As String
Dim strSQLEmployees As String
Dim varDate As Variant

' Open connection
strCnxn = "Provider=sqloledb;Data Source=MyServer;Initial Catalog=Pubs;User Id=sa;Password=; "
Set Cnxn = New ADODB.Connection
Cnxn.Open strCnxn

' Open employee table
Set rstEmployees = New ADODB.Recordset
strSQLEmployees = "employee"
rstEmployees.Open strSQLEmployees, Cnxn, adOpenKeyset, adLockOptimistic, adCmdTable

' Assign the first employee record's hire date
' to a variable, then change the hire date
varDate = rstEmployees!hire_date
Debug.Print "Original data"
Debug.Print " Name - Hire Date"
Debug.Print " " & rstEmployees!fname & " " & _
rstEmployees!lname & " - " & rstEmployees!hire_date
rstEmployees!hire_date = #1/1/1900#
rstEmployees.Update
Debug.Print "Changed data"
Debug.Print " Name - Hire Date"
Debug.Print " " & rstEmployees!fname & " " & _
rstEmployees!lname & " - " & rstEmployees!hire_date

' Requery Recordset and reset the hire date
rstEmployees.Requery
rstEmployees!hire_date = varDate
rstEmployees.Update
Debug.Print "Data after reset"
Debug.Print " Name - Hire Date"
Debug.Print " " & rstEmployees!fname & " " & _
rstEmployees!lname & " - " & rstEmployees!hire_date

rstEmployees.Close
Cnxn.Close
Set rstEmployees = Nothing
Set Cnxn = Nothing

End Sub
'EndOpenVB

一脚滑倒 2001-12-05
  • 打赏
  • 举报
回复
我倒!你的回答好简单!
有谁能我如何在ACCESS里设置这些???
相关推荐
发帖
VB基础类

7681

社区成员

VB 基础类
社区管理员
  • VB基础类社区
加入社区
帖子事件
创建了帖子
2001-12-05 09:22
社区公告
暂无公告