如果可以,我们可以从 Iron Python 脚本文件访问 SQL Server 数据吗?我如何尝试以下代码?
import sys
import clr
clr.AddReference("System.Windows")
from System.Windows import Application
import pypyodbc
constr="DRIVER={SQL Server Native Client 10.0};Data Source=SERVERName;Initial Catalog=DBName;Integrated Security=True"
cnxn=pypyodbc.connect(constr)
da=cnxn.cursor("Select Ename from tbl_Empployee where Emp_id=1",cn)
da.execute();
for row in da.fetchall():
for field in row:
Application.Current.RootVisual.FindName("textBox2").Text = field