如果列表框中没有其他项目,并且用户点击了下一个'按钮,我希望系统在数据库中插入一行...但数据库中没有任何内容。有人可以帮忙吗?
Sub ReplaceComments()
Dim cmt As Comment
Dim wks As Worksheet
Dim sFind As String
Dim sReplace As String
Dim sCmt As String
sFind = "2011"
sReplace = "2012"
For Each wks In ActiveWorkbook.Worksheets
For Each cmt In wks.Comments
sCmt = cmt.Text
If InStr(sCmt, sFind) <> 0 Then
sCmt = Application.WorksheetFunction. _
Substitute(sCmt, sFind, sReplace)
cmt.Text Text:=sCmt
End If
Next
Next
Set wks = Nothing
Set cmt = Nothing
End Sub
答案 0 :(得分:0)
你必须使用:
SqlCommand cmd = new SqlCommand Instead of
OleDbCommand cmd = new OleDbCommand
与SqlConnection
所有OleDb
更改为Sql
;
确保connection string
用于SQL Server
;