0

在我的代码的第 4 行,那里如何或可能有条件?

例如:

Dim expr As String = "SELECT * FROM [Sheet1$] WHERE excelColumn1 <> NULL "

我已经尝试过了,但它给出了一个错误:没有为一个或多个必需参数提供值。

    Dim ExcelConnection As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\z.fontanilla\Documents\etl2.xlsx;Extended Properties=""Excel 12.0 Xml;HDR=Yes""")
    ExcelConnection.Open()

    Dim expr As String = "SELECT * FROM [Sheet1$]"
    Dim objCmdSelect As OleDbCommand = New OleDbCommand(expr, ExcelConnection)

    Dim objDR As OleDbDataReader

    Dim SQLconn As New SqlConnection()
    Dim ConnString As String = "Data Source=cyayay\sqlexpress;Initial Catalog=reportingDB;Integrated Security=True"
    SQLconn.ConnectionString = ConnString
    SQLconn.Open()


    Using bulkCopy As SqlBulkCopy = New SqlBulkCopy(SQLconn)
        bulkCopy.DestinationTableName = "tFalse"

        Try
            objDR = objCmdSelect.ExecuteReader
            bulkCopy.BatchSize = 5000
            bulkCopy.WriteToServer(objDR)
            objDR.Close()
            SQLconn.Close()

        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Using
    ExcelConnection.Close()
4

0 回答 0