我的Excel VBA上有以下代码:
Sub Button3_Click()
Dim conn As New ADODB.Connection
With Sheets("Sheet1")
conn.Open "Provider=SQLNCLI11;Server=myServer;Database=myDatabase;Trusted_Connection=yes;"
iRowNo = 6
Do Until .Cells(iRowNo, 1) = ""
dtDateTime = .Cells(iRowNo, 1)
sTag = .Cells(iRowNo, 10)
conn.Execute "insert into RawData(oDateTime,oTag) values ('" & dtDateTime & "', '" & sTag & "')"
iRowNo = iRowNo + 1
Application.StatusBar = "Processing..."
Loop
MsgBox "Upload success!", vbInformation, "AOA"
Sheet1.Range("A6", "L100000").ClearContents
Sheet1.Cells(6, 1).Select
conn.Close
Set conn = Nothing
End With
End Sub
如果您检查上面的代码,则有两个值要添加到表中。当sTag
单元格为空时,是否可以跳过记录?
如果sTag
单元格为null,则插入下一条记录。这样的事情。
请帮助。
谢谢。
答案 0 :(得分:4)
您可以有条件地执行插入操作,即在If
语句中执行insert insert命令执行,在此语句中检查sTag
是否为空。
If sTag <> "" Then
conn.Execute "insert into RawData(oDateTime,oTag) values ('" & dtDateTime & "', '" & sTag & "')"
End If
答案 1 :(得分:1)
尝试:
<html>
<body>
<input id = "text1" type ="text"/>
</body>
<script>
function dumpCSSText(element){
var s = '';
var o = window.getComputedStyle(element);
for(var i = 0; i < o.length; i++){
s+=o[i] + ':' + o.getPropertyValue(o[i])+';';
}
return s;
}
console.log(dumpCSSText(document.getElementById("text1")));
</script>
</html>