在读取钉钉接口数据记录时,有时会遇到无效数据情况,此时,返回是空值,用空值读入数据表自然会提出引用错误提示。如何判断是为空值并跳过呢?代码如下,但不起作用,同样提示错误并终止运行,如何办?谢谢!Dim access_token As String=Functions.Execute("access_token")
Dim client As DingTalk.API.IDingTalkClient = new DingTalk.API.DefaultDingTalkClient("https://oapi.dingtalk.com/user/listbypage")
Dim req As DingTalk.API.Request.OapiUserListbypageRequest = new DingTalk.API.Request.OapiUserListbypageRequest()
Dim rsp As DingTalk.API.Response.OapiUserListbypageResponse
req.SetHttpMethod("GET")
req.Offset = 0L
req.Size = 50L
Dim xx As String
Dim jo As JObject
Dim ja As JArray
Dim dr As DataRow
For Each dr1 As DataRow In DataTables("departmentlist").DataRows
xx=dr1("department_ID")
req.DepartmentId =xx
rsp= client.Execute(req, access_token)
jo= JObject.Parse(rsp.body)
ja = jo("userlist")
For i As Integer = 0 To ja.Count - 1
dr = DataTables("user_ifo").Find("user_id = '" & ja(i)("userid").Tostring & "'")
If dr Is Nothing Then
dr=DataTables("user_ifo").addnew()
dr("name")=ja(i)("name").Tostring
dr("user_id")=ja(i)("userid").Tostring
dr("department_id")=xx
dr("department_name")=dr1("department_name")
If ja(i)("mobile") Is system.DBnull.value Then
Continue For
Else
dr("mobile")=ja(i)("mobile").Tostring
End If
dr.save()
End If
Next
Next