$conn = ObjCreate("ADODB.Connection")
$RS = ObjCreate("ADODB.Recordset")
$conn.Open("driver={SQL Server};server=" & $mdb_data_Server & ";uid=" & $mdb_data_id & ";pwd=" & $mdb_data_pwd & ";database=" & $mdb_data_Company)
$RS.ActiveConnection = $conn
$RS.Open("SELECT COUNT(*) FROM ( select b.name from sysobjects as a, syscolumns as b where a.xtype = 'U' and a.id = b.id and a.name='[01mon]' ) as a Where name='2019sx'") ;读取这一列的列名称
While (Not $RS.eof And Not $RS.bof) ;循环读表 有资料就跑回圈 没资料就会跳出
$pdz = $RS.Fields(0).value ;此位置真不知道在AU3中是如何用数据集里面的参数来表达返回值的
$RS.movenext
WEnd
MsgBox(0, "判断值", $pdz)
If $pdz = 0 Then
$conn = ObjCreate("ADODB.Connection")
$RS = ObjCreate("ADODB.Recordset")
$conn.Open("driver={SQL Server};server=" & $mdb_data_Server & ";uid=" & $mdb_data_id & ";pwd=" & $mdb_data_pwd & ";database=" & $mdb_data_Company)
$RS.ActiveConnection = $conn
$RS.Open("ALTER TABLE [" & $mon & "mon" & "] ADD [" & $sxlm & "] FLOAT DEFAULT 'null'")
$RS.Open("ALTER TABLE [" & $mon & "mon" & "] ADD [" & $cslm & "] FLOAT DEFAULT 'null'")
$conn.close
MsgBox(0, "创建成功", "!!!!!!!")
bc()
Else
bc()
EndIf
EndIf
这样出来的$pdz 不管你是有2019sx列 还是没有2019sx列 它的值都是0
|