当前位置:网站首页>Write VBA in Excel, connect to Oracle and query the contents in the database

Write VBA in Excel, connect to Oracle and query the contents in the database

2022-07-07 09:37:00 CSDN Q & A

stay EXCEL Write VBA Connect ORACLE And query the contents in the database
Sub searchDB()
Set CNN = CreateObject("ADODB.Connection")Set rst = CreateObject("ADODB.Recordset")CNN.Open "Driver={Oracle in instantclient_19_14};Dbq=mesproc;User Id=IQC_CHECKER;Password=iqc_123456;"Set rst = CNN.Execute("select iqc.no from MES_PROD.IQC_BILL iqc where iqc.no = '" & ActiveSheet.Cells(1, 2) & " '")For j = 0 To rst.Fields.Count - 1  Cells(1, j + 1) = rst.Fields(j).NameNextRange("A1").CopyFromRecordset rstCNN.Close

End Sub

You can connect successfully, but you don't know how to modify the content , I can write VBA Inquire about SQLSERVER Of , But I don't know ORACLE How to write . For example, I know the name of column , How to write SELECT FROM Then select that cell copyfrom I will only follow the template to draw gourd and gourd So I won't write
Want to base NO No. found The value of each column
原网站

版权声明
本文为[CSDN Q & A]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202206301436275654.html