April 6, 2011 at 10:09 am
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Public Class ScriptMain
Public Const Constring As String = "Provider=SQLOLEDB.1;User ID=;Password=;Initial Catalog=;Data Source="
Public Conn As System.Data.OleDb.OleDbConnection
' The execution engine calls this method when the task executes.
' To access the object model, use the Dts object. Connections, variables, events,
' and logging features are available as static members of the Dts class.
' Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
'
' To open Code and Text Editor Help, press F1.
' To open Object Browser, press Ctrl+Alt+J.
Public Sub Main()
'
' Add your code here
'
AssignFileName("\SSM\")
AssignFileName("\TTV\WindSor\")
Dts.TaskResult = Dts.Results.Success
End Sub
Public Sub AssignFileName(ByVal strSource As String)
Dim Fso As FileIO.FileSystem
Fso = New FileIO.FileSystem
Dim LogTable As System.Data.DataTable
Dim Adaptr As System.Data.OleDb.OleDbDataAdapter
LogTable = New System.Data.DataTable("LogTable")
OpenConnection()
Adaptr = New OleDb.OleDbDataAdapter("Select * from tbldataloadfiles", Conn)
Adaptr.Fill(LogTable)
Fso = New FileIO.FileSystem
Dim iEnum As Collections.IEnumerator
Dim filename As String
Dim strFileDate As String
Dim FileDate As Date
iEnum = Fso.GetFiles(strSource).GetEnumerator()
Dim drAddr() As DataRow
While iEnum.MoveNext
filename = iEnum.Current.ToString().Replace(strSource, "")
drAddr = LogTable.Select("VchFileName='" & filename & "'")
If drAddr.Length = 0 Then
Dim Cmd As OleDb.OleDbCommand
Cmd = New System.Data.OleDb.OleDbCommand("Insert into tbldataloadfiles (VchFileName) values ( '" & filename & "' )", Conn)
Cmd.ExecuteNonQuery()
Cmd = Nothing
End If
End While
End Sub
Public Sub OpenConnection()
Try
Conn = New System.Data.OleDb.OleDbConnection(Constring)
If Conn.State = ConnectionState.Closed Then Conn.Open()
Catch ex As Exception
Throw New Exception(ex.ToString)
End Try
End Sub
End Class
April 6, 2011 at 12:13 pm
is there a question?
Lowell
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy