Catch ex As Exception
Throw New Exception(ex.Message)
Finally
If iConn.State <> ConnectionState.Closed Then
iConn.Close()
End If
End Try
Return ds.Tables(iTableId)
End Function
Public Function ExcuteNoQuery(ByVal sqlString As String) As Boolean
Dim iConn As System.Data.IDbConnection = Me.GetConnection
Dim i As Integer = -1
Try
Dim iCommand As System.Data.IDbCommand = Me.GetCommand(sqlString, iConn)
If iConn.State <> ConnectionState.Open Then
iConn.Open()
End If
i = iCommand.ExecuteNonQuery()
Catch ex As Exception
Throw New Exception(ex.Message)
Return False
Exit Function
Finally
If iConn.State <> ConnectionState.Closed Then
iConn.Close()
End If
End Try
Return True
End Function
End Class
'//调用方法
'// dim OpXLS As New COpDB("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & 路径)
'// Me.OpXLS.ExcuteNoQuery("执行的非查询SQL语句")
'// dim ds as new DataSet = Me.OpXLS.ExcuteQuery("执行的查询语句") '//查询出来多个结果视图
'// dim dt as new DataTable = Me.OpXLS.ExcuteQuery("执行的查询语句",结果表序号(这里如果只是一条查询默认写0)) '//查询出来一个结果视图