473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Newbee - Project with single module.

Hi Guys,
I writing a project with just one module in it (the reason for this is to
debug code before it becomes a service) and am getting an error which I do
not understand:

No accessible 'Main' method with an appropriate signature was found in
'FTP_Log_Watcher'.

I have set the properties of FTP_Log_Watcher to Startup with 'Sub Main'.

I used to use VB6 about 3-4 years ago, but only as an amatuer. I have only
been using Visual Basic for 2 months - please go easy if it is obvious to you.

Below is the module:

Imports System.IO
Imports System.Data

Public Class EDI_Watcher

Dim gSQLCommandBuilder As System.Data.SqlClient.SqlCommandBuilder
Dim gDataAdapter As System.Data.SqlClient.SqlDataAdapter
Dim gCurrentExample As Integer

Private sDatabase As String
Private sServer As String
Private sUserID As String
Private sPassword As String
Private sConnectionString As String
Private cnn As System.Data.SqlClient.SqlConnection
Private cmd As System.Data.SqlClient.SqlCommand

Public WriteOnly Property Database()
Set(ByVal Value)
sDatabase = Value
End Set
End Property

Public WriteOnly Property Server()
Set(ByVal Value)
sServer = Value
End Set
End Property

Public WriteOnly Property UserID()
Set(ByVal Value)
sUserID = Value
End Set
End Property

Public WriteOnly Property Password()
Set(ByVal Value)
sPassword = Value
End Set
End Property

Public Sub Main(ByVal args() As String)
Call Watcher()
End Sub

Public Sub Watcher()

Const ForReading = 1, ForWriting = 2

Dim MyFileObject
Dim ScriptTimeout
Dim DebugFlag As Boolean
Dim MyFolder
Dim SubFolder
Dim Folder
Dim Date_Comps
Dim Log_Dir

Dim CurrentFolder
Dim FileColl

Dim objFile

Dim strDbInfo As String

Dim Source_Dir
Dim NI_FTP_Dir
Dim Tradanet_Dir
Dim RASCAL_Dir

MyFileObject = CreateObject("Scripting.FileSystemObject")

ScriptTimeout = 9999
'##### DEBUGGING SWITCH #####
DebugFlag =
System.Configuration.ConfigurationSettings.AppSett ings("Debug")
Dim strDebug As String
If DebugFlag = True Then strDebug = "Debug_"
'###########################

'################## Change Path HERE ##########################

'#### Path is read from app.config file. ####
Source_Dir =
System.Configuration.ConfigurationSettings.AppSett ings(strDebug &
"SourcePath")
'################## Change Path HERE ##########################

MyFolder = MyFileObject.GetFolder(Source_Dir)
Folder = MyFileObject.getfolder(MyFolder)
FileColl = CurrentFolder.Files

Dim dFolder As DirectoryInfo = New DirectoryInfo(Folder.path)
Dim fFileArray() As FileInfo = dFolder.GetFiles
' 'FILEARRAY' NOW HOLDS ALL THE FILES IN THE SELECTED FOLDER

Dim fFile As FileInfo

' LOOP THROUGH ARRAY, LISTING ALL FILES IN LISTVIEW
For Each fFile In fFileArray

'Pass filename, filedate, filelastmodified and filesize to SP
'to check if file has changed since last program execution.
strDbInfo = SimpleStoredProcedurewithArguments(fFile.Name)

Next
'################################################# ##############################################
End Sub

Public Function SimpleStoredProcedurewithArguments(ByVal Parameter As
String) As String

Try

Dim sStoredProcedure As String
Dim dr As System.Data.SqlClient.SqlDataReader
Dim pr As System.Data.SqlClient.SqlParameter
Dim sResults As String

'****************************************
' SET UP THE DATABASE CONNECTION
'****************************************

BuildConnectionString()
ConnectToDatabase()

'****************************************
' SET UP THE STORED PROCEDURE
'****************************************

sStoredProcedure = "SimpleStoredProcedurewithArguments"

cmd = New System.Data.SqlClient.SqlCommand(sStoredProcedure, cnn)
cmd.CommandType = System.Data.CommandType.StoredProcedure

'****************************************
' SET UP PARAMETER
'****************************************

pr = cmd.Parameters.Add("@LogFileName",
System.Data.SqlDbType.VarChar, 50)
pr.Direction = System.Data.ParameterDirection.Input

pr.Value = Parameter + "%"

'****************************************
' RUN THE STORED PROCEDURE
'****************************************

dr = cmd.ExecuteReader()

'****************************************
' SHOW THE RESULTS
'****************************************

sResults = "LogFileName" + vbTab + "LogFileDate" + vbTab + vbTab
+ "LogLastModified" + vbCrLf + vbCrLf + "LogFileSize"

While dr.Read()

sResults = sResults + dr.Item("LogFileName") + vbTab + vbTab
sResults = sResults + dr.Item("LogFileDate") + vbTab + vbTab
sResults = sResults + dr.Item("LogLastModified") + vbTab +
vbTab
sResults = sResults + dr.Item("LogFileSize") + vbTab

End While

dr.Close()

Return sResults

Catch GetError As System.Exception

End Try

End Function

Public Function SimpleStoredProcedureMultipleResults() As String

Try

Dim sStoredProcedure As String
Dim dr As System.Data.SqlClient.SqlDataReader
Dim sResults As String
Dim bNextResult As Boolean
Dim iFields As Integer
Dim iFieldAt As Integer

'****************************************
' SET UP THE DATABASE CONNECTION
'****************************************

BuildConnectionString()
ConnectToDatabase()

'****************************************
' SET UP THE STORED PROCEDURE
'****************************************

sStoredProcedure = "SimpleStoredProcedureMultipleResults"

cmd = New System.Data.SqlClient.SqlCommand(sStoredProcedure, cnn)
cmd.CommandType = System.Data.CommandType.StoredProcedure

'****************************************
' RUN THE STORED PROCEDURE
'****************************************

dr = cmd.ExecuteReader()

'****************************************
' SHOW THE RESULTS
'****************************************

sResults = ""

bNextResult = True

'****************************************
' LOOP THROUGH EACH RESULT
'****************************************
Do Until Not bNextResult

' HOW MANY FIELD/COLUMNS DO WE HAVE
iFields = dr.FieldCount() - 1

While dr.Read()

' LOOP THROUGH EACH FIELD/COLUMN
For iFieldAt = 0 To iFields
sResults = sResults + CStr(dr.Item(iFieldAt)) + vbTab
Next

' LINE BREAK FOR THE ROW
sResults = sResults + vbCrLf

End While

sResults = sResults + vbCrLf + vbCrLf

bNextResult = dr.NextResult

Loop

Return sResults

dr.Close()

Catch GetError As System.Exception

End Try

End Function

Public Sub BuildConnectionString()

'*************************************************
' BUILD THE CONNECTION STRING
'*************************************************
sConnectionString = "SERVER=" + "(local)" + ";"
sConnectionString = sConnectionString + "User ID=" + "newsco" + ";"
sConnectionString = sConnectionString + "Password=" + "nes0lt12" + ";"
sConnectionString = sConnectionString + "Initial Catalog=" +
"EDIExchange"

End Sub
Public Sub ConnectToDatabase()

'*************************************************
' CONNECT TO THE DATABASE
'*************************************************
cnn = New System.Data.SqlClient.SqlConnection(sConnectionStr ing)

cnn.Open()

End Sub

End Class

--
Kind Regards
John.
Sep 17 '06 #1
4 1170
Try taking the parameter list out of the main signature - VB doesn't use
that. For capturing the command line arguments use
Microsoft.VisualBasic.Command() and parse the resulting string.

Tom

John please don't spam me! wrote:
>Hi Guys,
I writing a project with just one module in it (the reason for this is to
debug code before it becomes a service) and am getting an error which I do
not understand:

No accessible 'Main' method with an appropriate signature was found in
'FTP_Log_Watcher'.

I have set the properties of FTP_Log_Watcher to Startup with 'Sub Main'.

I used to use VB6 about 3-4 years ago, but only as an amatuer. I have only
been using Visual Basic for 2 months - please go easy if it is obvious to you.

Below is the module:

Imports System.IO
Imports System.Data

Public Class EDI_Watcher

Dim gSQLCommandBuilder As System.Data.SqlClient.SqlCommandBuilder
Dim gDataAdapter As System.Data.SqlClient.SqlDataAdapter
Dim gCurrentExample As Integer

Private sDatabase As String
Private sServer As String
Private sUserID As String
Private sPassword As String
Private sConnectionString As String
Private cnn As System.Data.SqlClient.SqlConnection
Private cmd As System.Data.SqlClient.SqlCommand

Public WriteOnly Property Database()
Set(ByVal Value)
sDatabase = Value
End Set
End Property

Public WriteOnly Property Server()
Set(ByVal Value)
sServer = Value
End Set
End Property

Public WriteOnly Property UserID()
Set(ByVal Value)
sUserID = Value
End Set
End Property

Public WriteOnly Property Password()
Set(ByVal Value)
sPassword = Value
End Set
End Property

Public Sub Main(ByVal args() As String)
Call Watcher()
End Sub

Public Sub Watcher()

Const ForReading = 1, ForWriting = 2

Dim MyFileObject
Dim ScriptTimeout
Dim DebugFlag As Boolean
Dim MyFolder
Dim SubFolder
Dim Folder
Dim Date_Comps
Dim Log_Dir

Dim CurrentFolder
Dim FileColl

Dim objFile

Dim strDbInfo As String

Dim Source_Dir
Dim NI_FTP_Dir
Dim Tradanet_Dir
Dim RASCAL_Dir

MyFileObject = CreateObject("Scripting.FileSystemObject")

ScriptTimeout = 9999
'##### DEBUGGING SWITCH #####
DebugFlag =
System.Configuration.ConfigurationSettings.AppSet tings("Debug")
Dim strDebug As String
If DebugFlag = True Then strDebug = "Debug_"
'###########################

'################## Change Path HERE ##########################

'#### Path is read from app.config file. ####
Source_Dir =
System.Configuration.ConfigurationSettings.AppSet tings(strDebug &
"SourcePath")
'################## Change Path HERE ##########################

MyFolder = MyFileObject.GetFolder(Source_Dir)
Folder = MyFileObject.getfolder(MyFolder)
FileColl = CurrentFolder.Files

Dim dFolder As DirectoryInfo = New DirectoryInfo(Folder.path)
Dim fFileArray() As FileInfo = dFolder.GetFiles
' 'FILEARRAY' NOW HOLDS ALL THE FILES IN THE SELECTED FOLDER

Dim fFile As FileInfo

' LOOP THROUGH ARRAY, LISTING ALL FILES IN LISTVIEW
For Each fFile In fFileArray

'Pass filename, filedate, filelastmodified and filesize to SP
'to check if file has changed since last program execution.
strDbInfo = SimpleStoredProcedurewithArguments(fFile.Name)

Next
'################################################ ###############################################
End Sub

Public Function SimpleStoredProcedurewithArguments(ByVal Parameter As
String) As String

Try

Dim sStoredProcedure As String
Dim dr As System.Data.SqlClient.SqlDataReader
Dim pr As System.Data.SqlClient.SqlParameter
Dim sResults As String

'****************************************
' SET UP THE DATABASE CONNECTION
'****************************************

BuildConnectionString()
ConnectToDatabase()

'****************************************
' SET UP THE STORED PROCEDURE
'****************************************

sStoredProcedure = "SimpleStoredProcedurewithArguments"

cmd = New System.Data.SqlClient.SqlCommand(sStoredProcedure, cnn)
cmd.CommandType = System.Data.CommandType.StoredProcedure

'****************************************
' SET UP PARAMETER
'****************************************

pr = cmd.Parameters.Add("@LogFileName",
System.Data.SqlDbType.VarChar, 50)
pr.Direction = System.Data.ParameterDirection.Input

pr.Value = Parameter + "%"

'****************************************
' RUN THE STORED PROCEDURE
'****************************************

dr = cmd.ExecuteReader()

'****************************************
' SHOW THE RESULTS
'****************************************

sResults = "LogFileName" + vbTab + "LogFileDate" + vbTab + vbTab
+ "LogLastModified" + vbCrLf + vbCrLf + "LogFileSize"

While dr.Read()

sResults = sResults + dr.Item("LogFileName") + vbTab + vbTab
sResults = sResults + dr.Item("LogFileDate") + vbTab + vbTab
sResults = sResults + dr.Item("LogLastModified") + vbTab +
vbTab
sResults = sResults + dr.Item("LogFileSize") + vbTab

End While

dr.Close()

Return sResults

Catch GetError As System.Exception

End Try

End Function

Public Function SimpleStoredProcedureMultipleResults() As String

Try

Dim sStoredProcedure As String
Dim dr As System.Data.SqlClient.SqlDataReader
Dim sResults As String
Dim bNextResult As Boolean
Dim iFields As Integer
Dim iFieldAt As Integer

'****************************************
' SET UP THE DATABASE CONNECTION
'****************************************

BuildConnectionString()
ConnectToDatabase()

'****************************************
' SET UP THE STORED PROCEDURE
'****************************************

sStoredProcedure = "SimpleStoredProcedureMultipleResults"

cmd = New System.Data.SqlClient.SqlCommand(sStoredProcedure, cnn)
cmd.CommandType = System.Data.CommandType.StoredProcedure

'****************************************
' RUN THE STORED PROCEDURE
'****************************************

dr = cmd.ExecuteReader()

'****************************************
' SHOW THE RESULTS
'****************************************

sResults = ""

bNextResult = True

'****************************************
' LOOP THROUGH EACH RESULT
'****************************************
Do Until Not bNextResult

' HOW MANY FIELD/COLUMNS DO WE HAVE
iFields = dr.FieldCount() - 1

While dr.Read()

' LOOP THROUGH EACH FIELD/COLUMN
For iFieldAt = 0 To iFields
sResults = sResults + CStr(dr.Item(iFieldAt)) + vbTab
Next

' LINE BREAK FOR THE ROW
sResults = sResults + vbCrLf

End While

sResults = sResults + vbCrLf + vbCrLf

bNextResult = dr.NextResult

Loop

Return sResults

dr.Close()

Catch GetError As System.Exception

End Try

End Function

Public Sub BuildConnectionString()

'*************************************************
' BUILD THE CONNECTION STRING
'*************************************************
sConnectionString = "SERVER=" + "(local)" + ";"
sConnectionString = sConnectionString + "User ID=" + "newsco" + ";"
sConnectionString = sConnectionString + "Password=" + "nes0lt12" + ";"
sConnectionString = sConnectionString + "Initial Catalog=" +
"EDIExchange"

End Sub
Public Sub ConnectToDatabase()

'*************************************************
' CONNECT TO THE DATABASE
'*************************************************
cnn = New System.Data.SqlClient.SqlConnection(sConnectionStr ing)

cnn.Open()

End Sub

End Class
Sep 17 '06 #2
John,

We do not know what version you are using and the way you change this is
different.

However you have to set in your Project Properties in solution explorer your
Startup point.

Mostly is this Sub Main, however in a form that is integrated and you start
with Form.
Probably have you removed that Form from your class and do you have to
change the startup point.

This is always difficult to describe, moreover because it is in the two
versions different. In 2005 you have to change the form for a concole
application to let it go.

I hope this helps,

Cor

"John please don't spam me!"
<Jo******************@discussions.microsoft.comsch reef in bericht
news:C2**********************************@microsof t.com...
Hi Guys,
I writing a project with just one module in it (the reason for this is to
debug code before it becomes a service) and am getting an error which I do
not understand:

No accessible 'Main' method with an appropriate signature was found in
'FTP_Log_Watcher'.

I have set the properties of FTP_Log_Watcher to Startup with 'Sub Main'.

I used to use VB6 about 3-4 years ago, but only as an amatuer. I have
only
been using Visual Basic for 2 months - please go easy if it is obvious to
you.

Below is the module:

Imports System.IO
Imports System.Data

Public Class EDI_Watcher

Dim gSQLCommandBuilder As System.Data.SqlClient.SqlCommandBuilder
Dim gDataAdapter As System.Data.SqlClient.SqlDataAdapter
Dim gCurrentExample As Integer

Private sDatabase As String
Private sServer As String
Private sUserID As String
Private sPassword As String
Private sConnectionString As String
Private cnn As System.Data.SqlClient.SqlConnection
Private cmd As System.Data.SqlClient.SqlCommand

Public WriteOnly Property Database()
Set(ByVal Value)
sDatabase = Value
End Set
End Property

Public WriteOnly Property Server()
Set(ByVal Value)
sServer = Value
End Set
End Property

Public WriteOnly Property UserID()
Set(ByVal Value)
sUserID = Value
End Set
End Property

Public WriteOnly Property Password()
Set(ByVal Value)
sPassword = Value
End Set
End Property

Public Sub Main(ByVal args() As String)
Call Watcher()
End Sub

Public Sub Watcher()

Const ForReading = 1, ForWriting = 2

Dim MyFileObject
Dim ScriptTimeout
Dim DebugFlag As Boolean
Dim MyFolder
Dim SubFolder
Dim Folder
Dim Date_Comps
Dim Log_Dir

Dim CurrentFolder
Dim FileColl

Dim objFile

Dim strDbInfo As String

Dim Source_Dir
Dim NI_FTP_Dir
Dim Tradanet_Dir
Dim RASCAL_Dir

MyFileObject = CreateObject("Scripting.FileSystemObject")

ScriptTimeout = 9999
'##### DEBUGGING SWITCH #####
DebugFlag =
System.Configuration.ConfigurationSettings.AppSett ings("Debug")
Dim strDebug As String
If DebugFlag = True Then strDebug = "Debug_"
'###########################

'################## Change Path HERE ##########################

'#### Path is read from app.config file. ####
Source_Dir =
System.Configuration.ConfigurationSettings.AppSett ings(strDebug &
"SourcePath")
'################## Change Path HERE ##########################

MyFolder = MyFileObject.GetFolder(Source_Dir)
Folder = MyFileObject.getfolder(MyFolder)
FileColl = CurrentFolder.Files

Dim dFolder As DirectoryInfo = New DirectoryInfo(Folder.path)
Dim fFileArray() As FileInfo = dFolder.GetFiles
' 'FILEARRAY' NOW HOLDS ALL THE FILES IN THE SELECTED FOLDER

Dim fFile As FileInfo

' LOOP THROUGH ARRAY, LISTING ALL FILES IN LISTVIEW
For Each fFile In fFileArray

'Pass filename, filedate, filelastmodified and filesize to SP
'to check if file has changed since last program execution.
strDbInfo = SimpleStoredProcedurewithArguments(fFile.Name)

Next
'################################################# ##############################################
End Sub

Public Function SimpleStoredProcedurewithArguments(ByVal Parameter As
String) As String

Try

Dim sStoredProcedure As String
Dim dr As System.Data.SqlClient.SqlDataReader
Dim pr As System.Data.SqlClient.SqlParameter
Dim sResults As String

'****************************************
' SET UP THE DATABASE CONNECTION
'****************************************

BuildConnectionString()
ConnectToDatabase()

'****************************************
' SET UP THE STORED PROCEDURE
'****************************************

sStoredProcedure = "SimpleStoredProcedurewithArguments"

cmd = New System.Data.SqlClient.SqlCommand(sStoredProcedure,
cnn)
cmd.CommandType = System.Data.CommandType.StoredProcedure

'****************************************
' SET UP PARAMETER
'****************************************

pr = cmd.Parameters.Add("@LogFileName",
System.Data.SqlDbType.VarChar, 50)
pr.Direction = System.Data.ParameterDirection.Input

pr.Value = Parameter + "%"

'****************************************
' RUN THE STORED PROCEDURE
'****************************************

dr = cmd.ExecuteReader()

'****************************************
' SHOW THE RESULTS
'****************************************

sResults = "LogFileName" + vbTab + "LogFileDate" + vbTab +
vbTab
+ "LogLastModified" + vbCrLf + vbCrLf + "LogFileSize"

While dr.Read()

sResults = sResults + dr.Item("LogFileName") + vbTab +
vbTab
sResults = sResults + dr.Item("LogFileDate") + vbTab +
vbTab
sResults = sResults + dr.Item("LogLastModified") + vbTab +
vbTab
sResults = sResults + dr.Item("LogFileSize") + vbTab

End While

dr.Close()

Return sResults

Catch GetError As System.Exception

End Try

End Function

Public Function SimpleStoredProcedureMultipleResults() As String

Try

Dim sStoredProcedure As String
Dim dr As System.Data.SqlClient.SqlDataReader
Dim sResults As String
Dim bNextResult As Boolean
Dim iFields As Integer
Dim iFieldAt As Integer

'****************************************
' SET UP THE DATABASE CONNECTION
'****************************************

BuildConnectionString()
ConnectToDatabase()

'****************************************
' SET UP THE STORED PROCEDURE
'****************************************

sStoredProcedure = "SimpleStoredProcedureMultipleResults"

cmd = New System.Data.SqlClient.SqlCommand(sStoredProcedure,
cnn)
cmd.CommandType = System.Data.CommandType.StoredProcedure

'****************************************
' RUN THE STORED PROCEDURE
'****************************************

dr = cmd.ExecuteReader()

'****************************************
' SHOW THE RESULTS
'****************************************

sResults = ""

bNextResult = True

'****************************************
' LOOP THROUGH EACH RESULT
'****************************************
Do Until Not bNextResult

' HOW MANY FIELD/COLUMNS DO WE HAVE
iFields = dr.FieldCount() - 1

While dr.Read()

' LOOP THROUGH EACH FIELD/COLUMN
For iFieldAt = 0 To iFields
sResults = sResults + CStr(dr.Item(iFieldAt)) +
vbTab
Next

' LINE BREAK FOR THE ROW
sResults = sResults + vbCrLf

End While

sResults = sResults + vbCrLf + vbCrLf

bNextResult = dr.NextResult

Loop

Return sResults

dr.Close()

Catch GetError As System.Exception

End Try

End Function

Public Sub BuildConnectionString()

'*************************************************
' BUILD THE CONNECTION STRING
'*************************************************
sConnectionString = "SERVER=" + "(local)" + ";"
sConnectionString = sConnectionString + "User ID=" + "newsco" + ";"
sConnectionString = sConnectionString + "Password=" + "nes0lt12" +
";"
sConnectionString = sConnectionString + "Initial Catalog=" +
"EDIExchange"

End Sub
Public Sub ConnectToDatabase()

'*************************************************
' CONNECT TO THE DATABASE
'*************************************************
cnn = New System.Data.SqlClient.SqlConnection(sConnectionStr ing)

cnn.Open()

End Sub

End Class

--
Kind Regards
John.

Sep 18 '06 #3
1. VB.NEt 2003.
2. Project Properties have been set.
3. No Forms - Module Only Project!
4. Again No Forms!

All but the first one was covered in my original posting - Did u read it
before replying?
--
Kind Regards
John.
"Cor Ligthert [MVP]" wrote:
John,

We do not know what version you are using and the way you change this is
different.

However you have to set in your Project Properties in solution explorer your
Startup point.

Mostly is this Sub Main, however in a form that is integrated and you start
with Form.
Probably have you removed that Form from your class and do you have to
change the startup point.

This is always difficult to describe, moreover because it is in the two
versions different. In 2005 you have to change the form for a concole
application to let it go.

I hope this helps,

Cor

"John please don't spam me!"
<Jo******************@discussions.microsoft.comsch reef in bericht
news:C2**********************************@microsof t.com...
Hi Guys,
I writing a project with just one module in it (the reason for this is to
debug code before it becomes a service) and am getting an error which I do
not understand:

No accessible 'Main' method with an appropriate signature was found in
'FTP_Log_Watcher'.

I have set the properties of FTP_Log_Watcher to Startup with 'Sub Main'.

I used to use VB6 about 3-4 years ago, but only as an amatuer. I have
only
been using Visual Basic for 2 months - please go easy if it is obvious to
you.

Below is the module:

Imports System.IO
Imports System.Data

Public Class EDI_Watcher

Dim gSQLCommandBuilder As System.Data.SqlClient.SqlCommandBuilder
Dim gDataAdapter As System.Data.SqlClient.SqlDataAdapter
Dim gCurrentExample As Integer

Private sDatabase As String
Private sServer As String
Private sUserID As String
Private sPassword As String
Private sConnectionString As String
Private cnn As System.Data.SqlClient.SqlConnection
Private cmd As System.Data.SqlClient.SqlCommand

Public WriteOnly Property Database()
Set(ByVal Value)
sDatabase = Value
End Set
End Property

Public WriteOnly Property Server()
Set(ByVal Value)
sServer = Value
End Set
End Property

Public WriteOnly Property UserID()
Set(ByVal Value)
sUserID = Value
End Set
End Property

Public WriteOnly Property Password()
Set(ByVal Value)
sPassword = Value
End Set
End Property

Public Sub Main(ByVal args() As String)
Call Watcher()
End Sub

Public Sub Watcher()

Const ForReading = 1, ForWriting = 2

Dim MyFileObject
Dim ScriptTimeout
Dim DebugFlag As Boolean
Dim MyFolder
Dim SubFolder
Dim Folder
Dim Date_Comps
Dim Log_Dir

Dim CurrentFolder
Dim FileColl

Dim objFile

Dim strDbInfo As String

Dim Source_Dir
Dim NI_FTP_Dir
Dim Tradanet_Dir
Dim RASCAL_Dir

MyFileObject = CreateObject("Scripting.FileSystemObject")

ScriptTimeout = 9999
'##### DEBUGGING SWITCH #####
DebugFlag =
System.Configuration.ConfigurationSettings.AppSett ings("Debug")
Dim strDebug As String
If DebugFlag = True Then strDebug = "Debug_"
'###########################

'################## Change Path HERE ##########################

'#### Path is read from app.config file. ####
Source_Dir =
System.Configuration.ConfigurationSettings.AppSett ings(strDebug &
"SourcePath")
'################## Change Path HERE ##########################

MyFolder = MyFileObject.GetFolder(Source_Dir)
Folder = MyFileObject.getfolder(MyFolder)
FileColl = CurrentFolder.Files

Dim dFolder As DirectoryInfo = New DirectoryInfo(Folder.path)
Dim fFileArray() As FileInfo = dFolder.GetFiles
' 'FILEARRAY' NOW HOLDS ALL THE FILES IN THE SELECTED FOLDER

Dim fFile As FileInfo

' LOOP THROUGH ARRAY, LISTING ALL FILES IN LISTVIEW
For Each fFile In fFileArray

'Pass filename, filedate, filelastmodified and filesize to SP
'to check if file has changed since last program execution.
strDbInfo = SimpleStoredProcedurewithArguments(fFile.Name)

Next
'################################################# ##############################################
End Sub

Public Function SimpleStoredProcedurewithArguments(ByVal Parameter As
String) As String

Try

Dim sStoredProcedure As String
Dim dr As System.Data.SqlClient.SqlDataReader
Dim pr As System.Data.SqlClient.SqlParameter
Dim sResults As String

'****************************************
' SET UP THE DATABASE CONNECTION
'****************************************

BuildConnectionString()
ConnectToDatabase()

'****************************************
' SET UP THE STORED PROCEDURE
'****************************************

sStoredProcedure = "SimpleStoredProcedurewithArguments"

cmd = New System.Data.SqlClient.SqlCommand(sStoredProcedure,
cnn)
cmd.CommandType = System.Data.CommandType.StoredProcedure

'****************************************
' SET UP PARAMETER
'****************************************

pr = cmd.Parameters.Add("@LogFileName",
System.Data.SqlDbType.VarChar, 50)
pr.Direction = System.Data.ParameterDirection.Input

pr.Value = Parameter + "%"

'****************************************
' RUN THE STORED PROCEDURE
'****************************************

dr = cmd.ExecuteReader()

'****************************************
' SHOW THE RESULTS
'****************************************

sResults = "LogFileName" + vbTab + "LogFileDate" + vbTab +
vbTab
+ "LogLastModified" + vbCrLf + vbCrLf + "LogFileSize"

While dr.Read()

sResults = sResults + dr.Item("LogFileName") + vbTab +
vbTab
sResults = sResults + dr.Item("LogFileDate") + vbTab +
vbTab
sResults = sResults + dr.Item("LogLastModified") + vbTab +
vbTab
sResults = sResults + dr.Item("LogFileSize") + vbTab

End While

dr.Close()

Return sResults

Catch GetError As System.Exception

End Try

End Function

Public Function SimpleStoredProcedureMultipleResults() As String

Try

Dim sStoredProcedure As String
Dim dr As System.Data.SqlClient.SqlDataReader
Dim sResults As String
Dim bNextResult As Boolean
Dim iFields As Integer
Dim iFieldAt As Integer

'****************************************
' SET UP THE DATABASE CONNECTION
'****************************************

BuildConnectionString()
ConnectToDatabase()

'****************************************
' SET UP THE STORED PROCEDURE
'****************************************

sStoredProcedure = "SimpleStoredProcedureMultipleResults"

cmd = New System.Data.SqlClient.SqlCommand(sStoredProcedure,
cnn)
cmd.CommandType = System.Data.CommandType.StoredProcedure

'****************************************
' RUN THE STORED PROCEDURE
'****************************************

dr = cmd.ExecuteReader()

'****************************************
' SHOW THE RESULTS
'****************************************

sResults = ""

bNextResult = True

'****************************************
' LOOP THROUGH EACH RESULT
'****************************************
Do Until Not bNextResult

' HOW MANY FIELD/COLUMNS DO WE HAVE
iFields = dr.FieldCount() - 1

While dr.Read()

' LOOP THROUGH EACH FIELD/COLUMN
For iFieldAt = 0 To iFields
sResults = sResults + CStr(dr.Item(iFieldAt)) +
vbTab
Next

' LINE BREAK FOR THE ROW
sResults = sResults + vbCrLf

End While

sResults = sResults + vbCrLf + vbCrLf

bNextResult = dr.NextResult
Sep 19 '06 #4
John,
>
All but the first one was covered in my original posting - Did u read it
before replying?
--
I did not see it in this thread, do you mean that you are multiple times
putting this in this newsgroup?
Than put your questions about those in the original thread, than we can see
the answers from others, in this way it takes to much time.
Cor
Sep 20 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Hamed | last post by:
Hello Every where in .NET books is mentioned that VS.NET is a seamless cross platform environment. We have two groups of programmers that some are VB programmer but others prefer to use C#. Is it...
7
by: George Copeland | last post by:
This is a request for assistance analyzing a problem we are experiencing in our VB6 development environment. All our code is developed in VB6, and our persistance layer is SQL Server. We are...
3
by: Hamed | last post by:
Hello Every where in .NET books is mentioned that VS.NET is a seamless cross platform environment. We have two groups of programmers that some are VB programmer but others prefer to use C#. Is it...
49
by: Martin Unsal | last post by:
I'm using Python for what is becoming a sizeable project and I'm already running into problems organizing code and importing packages. I feel like the Python package system, in particular the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.