云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > VB连接数据库的方法2

VB连接数据库的方法2

  • 62 次阅读
  • 3 次下载
  • 2026/1/27 16:42:57

AdoCnn.CursorLocation = adUseClient

'.open后面的字符串可以参考ADO控件连接.ConnectionString后面的的字符串

AdoCnn.Open\Info=False;Data Source=\Properties='Excel 8.0;HDR=Yes'\

AdoRs.Open \adLockPessimistic, adCmdText

Set DataGrid1.DataSource = AdoRs Set AdoRs = Nothing Set AdoCnn = Nothing End Sub

4.'ADO代码与Oracle数据库连接 Private Sub Command4_Click() Dim AdoCnn As ADODB.Connection Dim AdoRs As ADODB.Recordset Set AdoCnn = New ADODB.Connection Set AdoRs = New ADODB.Recordset AdoCnn.CursorLocation = adUseClient

'.open后面的字符串可以参考ADO控件连接.ConnectionString后面的的字符串

AdoCnn.Open \Security Info=True;User ID=chncmadb;Data Source=towebserver\AdoRs.Open \adLockPessimistic, adCmdText

Set DataGrid1.DataSource = AdoRs

Set AdoRs = Nothing Set AdoCnn = Nothing End Sub

5.'ADO代码与SQLserver数据库连接 '未测试

Private Sub Command5_Click() Dim AdoCnn As ADODB.Connection Dim AdoRs As ADODB.Recordset Set AdoCnn = New ADODB.Connection Set AdoRs = New ADODB.Recordset AdoCnn.CursorLocation = adUseClient

'.open后面的字符串可以参考ADO控件连接.ConnectionString后面的的字符串

AdoCnn.Open \Info=True;User ID=111;Initial Catalog=111;Data Source=111\AdoRs.Open \adLockPessimistic, adCmdText

Set DataGrid1.DataSource = AdoRs Set AdoRs = Nothing Set AdoCnn = Nothing End Sub

连库

Dim DLYHM, DLMM, DLSLM As String Dim Grecordset As New ADODB.Recordset

Dim Gconnection_HQ As New ADODB.Connection DLYHM = \用户名 DLMM = \登录密码

DLSLM = \中的实例名 LSsjk = DLYHM + \

LSsjk = \ Set Gconnection_HQ = New ADODB.Connection Gconnection_HQ.Open LSsjk

读数据

Set Grecordset = New ADODB.Recordset

Grecordset.Open \* from 表名 where 字段名='\& 字段值 & \Gconnection_HQ, adOpenStatic, adLockOptimistic ‘索引条件 变量 = Trim(Grecordset.Fields(\读取字段名\Grecordset.Close

最好建ODBC配置数据源,然后连接

linkcn = \数据源名;Persist Security Info=True;User ID=用户;Password=密码 \

找tnsnames.ora文件,我的在oracle\\product\\10.2.0\\db_1\\NETWORK\\ADMIN下。 记事本打开后

……(DESCRIPTION = (ADDRESS =

(PROTOCOL = TCP)

(HOST = 远程服务器名或者IP地址) (PORT = 1521) )

(CONNECT_DATA = (SERVER = DEDICATED)

(SERVICE_NAME = 服务器的数据库名) ) ……

手动改一下好了~~

Microsoft ODBC for Oracle Type: ODBC Driver Usage: Driver={Microsoft ODBC for Oracle} Manufacturer: Microsoft More info about this driver ? Customize string example values ? New version Driver={Microsoft ODBC for Oracle};Server=myServerAddress;Uid=myUsername;Pwd=myPassword; Microsoft ODBC Driver for Oracle Type: ODBC Driver Usage: Driver={Microsoft ODBC Driver for Oracle} Manufacturer: Microsoft More info about this driver ? Customize string example values ? Old version Driver={Microsoft ODBC Driver for Oracle};ConnectString=OracleServer.world;Uid=myUsername;Pwd=myPassword;

搜索更多关于: VB连接数据库的方法2 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

AdoCnn.CursorLocation = adUseClient '.open后面的字符串可以参考ADO控件连接.ConnectionString后面的的字符串 AdoCnn.Open\Info=False;Data Source=\Properties='Excel 8.0;HDR=Yes'\AdoRs.Open \adLockPessimistic, adCmdText Set DataGrid1.DataSource = AdoRs Set AdoRs = Nothing Set AdoCnn = Nothing End Sub 4.'ADO代码与Oracle数据库连接 Private Sub Command4_Click() Dim AdoC

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com