找回密码
 注册

QQ登录

只需一步,快速开始

搜索

winccl与ORACLE

[复制链接]
sonypower 发表于 2016-7-8 22:23:45 | 显示全部楼层 |阅读模式
Dim objTag
    Dim strConnectionString
    Dim strSQL
    Dim lngCount
    Dim lngValue
    Dim objConnection, objRecordset, objCommand

Const hostName = "192.168.0.211"
Const portNo = "1522"
Const srvSID = "ORCL"
Const usrID = "ID"
Const usrPwd = "PASS"


  strDriver = "Driver={Microsoft ODBC for Oracle};"
  strParams = "CONNECTSTRING=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=" + hostName + ")(PORT=" + portNo + "))(CONNECT_DATA=(SID=" + srvSID + ")));"
  strUser = "UID=" + usrID + ";PWD=" + usrPwd + ";"

  strConnectionString = strDriver + strParams + strUser


     strConnectionString = "Provider=MSDASQL;DSN=orclConnect;UID=ID;PWD=PASS"
     strSQL = "select score from test where name = 'NAME'"
     Set objConnection = CreateObject("ADODB.Connection")
     objConnection.ConnectionString = strConnectionString
     objConnection.Open
     Set objRecordset = CreateObject("ADODB.Recordset")
     Set objCommand = CreateObject("ADODB.Command")
     objCommand.ActiveConnection = objConnection
     objCommand.CommandText = strSQL
     Set objRecordset = objCommand.Execute
     lngCount = objRecordset.Fields.Count
     If (lngCount > 0) Then
     objRecordset.movefirst
     lngValue = objRecordset.Fields(0).value
     End If

    Set objCommand = Nothing
    objConnection.Close
    Set objRecordset = Nothing
    Set objConnection = Nothing

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|ELEOK |网站地图

GMT+8, 2024-11-23 23:52

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表