找回密码
 加入
搜索
查看: 1485|回复: 3

[网络通信] Array(Empty, Empty, Empty, "VIEW")如何改写?[已解决]

[复制链接]
发表于 2019-8-15 22:43:38 | 显示全部楼层 |阅读模式
本帖最后由 cashiba 于 2019-8-16 00:10 编辑
Public Sub Main() 
 On Error GoTo ErrorHandler 
 
 Dim Cnxn2 As ADODB.Connection 
 Dim rstSchema As ADODB.Recordset 
 Dim strCnxn As String 
 
 Set Cnxn2 = New ADODB.Connection 
 strCnxn = "Provider=sqloledb;" & _ 
 "Data Source=MySqlServer;Initial Catalog=Pubs;Integrated Security=SSPI; " 
 Cnxn2.Open strCnxn 
 
 Set rstSchema = Cnxn2.OpenSchema(adSchemaTables, Array(Empty, Empty, Empty, "VIEW"))
 
 Do Until rstSchema.EOF 
 Debug.Print "Table name: " & _ 
 rstSchema!TABLE_NAME & vbCr & _ 
 "Table type: " & rstSchema!TABLE_TYPE & vbCr 
 rstSchema.MoveNext 
 Loop 
 
 rstSchema.Close 
 Cnxn2.Close 
 Set rstSchema = Nothing 
 Set Cnxn2 = Nothing 
 Exit Sub 
 
ErrorHandler: 
If Not rstSchema Is Nothing Then 
 If rstSchema.State = adStateOpen Then rstSchema.Close 
 End If 
 Set rstSchema = Nothing 
 
 If Not Cnxn2 Is Nothing Then 
 If Cnxn2.State = adStateOpen Then Cnxn2.Close 
 End If 
 Set Cnxn2 = Nothing 
 
 If Err <> 0 Then 
 MsgBox Err.Source & "-->" & Err.Description, , "Error" 
 End If 
End Sub 
.
Local $oCn = ObjCreate("adodb.connection")
Local $oRs = ObjCreate("adodb.recordset")
Local $sdb = @ScriptDir & "\Data.accdb"
Local $sPw = ""
Local $sCn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & $sdb & _
                ";persist Security Info=False;Jet OLEDB:Database Password=" & $sPw
$oCn.Open($sCn)

Local $t = ["", "", "", "VIEW"]
Local $oSm = $oCn.OpenSchema(20, $t)

Local $t = ["", "", "", "VIEW"]
Local $oSm = $oCn.OpenSchema(20, $t)
Local $oSm = $oCn.OpenSchema(20, $t)
Local $oSm = $oCn^ ERROR
Array(Empty, Empty, Empty, "VIEW")
$t = ["", "", "", "VIEW"]
$t = [Null, Null, Null, "VIEW"]
以上错误不知道是不是empty改成""或Null造成的......

AU3里空值好像也就""或Null以及0三种形式
不知道为啥运行有错误,还是问题不在这里呢.....
发表于 2019-8-15 23:10:53 | 显示全部楼层
索性"斩脚趾避沙虫"
$t[4]="VIEW"

评分

参与人数 1金钱 +20 收起 理由
cashiba + 20 赞一个!

查看全部评分

 楼主| 发表于 2019-8-15 23:37:17 | 显示全部楼层
chishingchan 发表于 2019-8-15 23:10
索性"斩脚趾避沙虫"
$t[4]="VIEW"

版主的办法确实可行,绕开了直接赋空值
不过经常会遇到空值空对象之类的问题,而且转换其它编程语言到AU3的时候也常遇到这种问题
像上述数组空元素,AU3里如何像VB、js一样有明确的变量或常量表示呢?


发表于 2019-8-16 21:12:29 | 显示全部楼层
要不学一下 Dictionary 对象
http://www.autoitx.com/thread-37424-1-1.html

评分

参与人数 1金钱 +20 收起 理由
cashiba + 20 很给力!

查看全部评分

您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-19 20:48 , Processed in 0.077614 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表