初学者,很多地方仅仅还是模仿.我参考别的代码,使用ADO控件通过设置ODBC连接Access能够成功,语句如下:
Dim objConnection
Dim strConnectionString
Dim lngValue
Dim strSQL
Dim objCommand
Dim testValue
strConnectionString="Provider=MSDASQL;DSN=SampleDSN;UID=s;PWD=s;"
lngValue = HMIRuntime.Tags("Tag1").Read
testValue=CStr(HMIRuntime.Tags("TextValue").Read)
strSQL="INSERT INTO WINCC_DATA(TagValue,TestValue)VALUES(" & lngValue &",'" & testValue &"');"
Set objConnection=CreateObject("ADODB.Connection")
objConnection.ConnectionString=strConnectionString
objConnection.Open
Set objCommand=CreateObject("ADODB.Command")
With objCommand
.ActiveConnection=objConnection
.CommandText=strSQL
End With
objCommand.Execute
Set objCommand=Nothing
objConnection.Close
Set objConnection=Nothing
这是写入的程序,读取的程序就不写了,与这类似.
问题:1,连接Oracle就不知道怎么弄了,请教一下各位大侠.
2,ODBC是一个端口,而ADO和OLEDB都是基于这个端口进行封装的,如果改用OLEDB的话是不是语句相差很大?
3,能够帮我大概介绍一下ODBC,ADO,OLEDB更好,因为这几种技术都不懂(介绍一下使用差异).