Historian实时数据库连接

时间:2017-10-01 02:42:14
【文件属性】:
文件名称:Historian实时数据库连接
文件大小:1KB
文件格式:TXT
更新时间:2017-10-01 02:42:14
Historian 实时数据库 Private Sub Command1_Click() Dim connection1 As New ADODB.Connection Dim recset1 As New ADODB.Recordset Dim iCount& Dim strConnectionString$ On Error GoTo ErrorHandler ' connect to default iHistorian server with default credentials strConnectionString$ = "Provider=ihOLEDB.iHistorian.1;User Id=;Password=" ' uncomment this if you want to connect to specific iHistorian server with a username and password 'strConnectionString$ = "Provider=ihOLEDB.iHistorian.1;Data Source=MYSERVER;User Id=user1;Password=password1" ' open connection connection1.ConnectionString = strConnectionString$ connection1.Open ' do the select. There are multiple ways to execute a command in ADO, this is just one recset1.Open "SELECT * FROM ihTags", connection1 ' print the output iCount = 0 Do While Not recset1.EOF Debug.Print recset1.Fields(0) recset1.MoveNext iCount = iCount + 1 Loop ' print a count of rows If iCount = 0 Then MsgBox "No rows were returned in the query" Else MsgBox iCount & " rows returned." End If ' close the recordset recset1.Close Set recset1 = Nothing ' close the connection connection1.Close Exit Sub ErrorHandler: MsgBox Err.Description End Sub

网友评论

  • 没积分了我来回评。。。。
  • 不是我要的资源,问题还有待解决