473,606 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Watche r'.

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 gSQLCommandBuil der As System.Data.Sql Client.SqlComma ndBuilder
Dim gDataAdapter As System.Data.Sql Client.SqlDataA dapter
Dim gCurrentExample As Integer

Private sDatabase As String
Private sServer As String
Private sUserID As String
Private sPassword As String
Private sConnectionStri ng As String
Private cnn As System.Data.Sql Client.SqlConne ction
Private cmd As System.Data.Sql Client.SqlComma nd

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("S cripting.FileSy stemObject")

ScriptTimeout = 9999
'##### DEBUGGING SWITCH #####
DebugFlag =
System.Configur ation.Configura tionSettings.Ap pSettings("Debu g")
Dim strDebug As String
If DebugFlag = True Then strDebug = "Debug_"
'############## #############

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

'#### Path is read from app.config file. ####
Source_Dir =
System.Configur ation.Configura tionSettings.Ap pSettings(strDe bug &
"SourcePath ")
'############## #### Change Path HERE ############### ###########

MyFolder = MyFileObject.Ge tFolder(Source_ Dir)
Folder = MyFileObject.ge tfolder(MyFolde r)
FileColl = CurrentFolder.F iles

Dim dFolder As DirectoryInfo = New DirectoryInfo(F older.path)
Dim fFileArray() As FileInfo = dFolder.GetFile s
' '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, filelastmodifie d and filesize to SP
'to check if file has changed since last program execution.
strDbInfo = SimpleStoredPro cedurewithArgum ents(fFile.Name )

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

Public Function SimpleStoredPro cedurewithArgum ents(ByVal Parameter As
String) As String

Try

Dim sStoredProcedur e As String
Dim dr As System.Data.Sql Client.SqlDataR eader
Dim pr As System.Data.Sql Client.SqlParam eter
Dim sResults As String

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

BuildConnection String()
ConnectToDataba se()

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

sStoredProcedur e = "SimpleStoredPr ocedurewithArgu ments"

cmd = New System.Data.Sql Client.SqlComma nd(sStoredProce dure, cnn)
cmd.CommandType = System.Data.Com mandType.Stored Procedure

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

pr = cmd.Parameters. Add("@LogFileNa me",
System.Data.Sql DbType.VarChar, 50)
pr.Direction = System.Data.Par ameterDirection .Input

pr.Value = Parameter + "%"

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

dr = cmd.ExecuteRead er()

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

sResults = "LogFileNam e" + vbTab + "LogFileDat e" + vbTab + vbTab
+ "LogLastModifie d" + vbCrLf + vbCrLf + "LogFileSiz e"

While dr.Read()

sResults = sResults + dr.Item("LogFil eName") + vbTab + vbTab
sResults = sResults + dr.Item("LogFil eDate") + vbTab + vbTab
sResults = sResults + dr.Item("LogLas tModified") + vbTab +
vbTab
sResults = sResults + dr.Item("LogFil eSize") + vbTab

End While

dr.Close()

Return sResults

Catch GetError As System.Exceptio n

End Try

End Function

Public Function SimpleStoredPro cedureMultipleR esults() As String

Try

Dim sStoredProcedur e As String
Dim dr As System.Data.Sql Client.SqlDataR eader
Dim sResults As String
Dim bNextResult As Boolean
Dim iFields As Integer
Dim iFieldAt As Integer

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

BuildConnection String()
ConnectToDataba se()

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

sStoredProcedur e = "SimpleStoredPr ocedureMultiple Results"

cmd = New System.Data.Sql Client.SqlComma nd(sStoredProce dure, cnn)
cmd.CommandType = System.Data.Com mandType.Stored Procedure

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

dr = cmd.ExecuteRead er()

'************** *************** ***********
' 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(iF ieldAt)) + 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.Exceptio n

End Try

End Function

Public Sub BuildConnection String()

'************** *************** *************** *****
' BUILD THE CONNECTION STRING
'************** *************** *************** *****
sConnectionStri ng = "SERVER=" + "(local)" + ";"
sConnectionStri ng = sConnectionStri ng + "User ID=" + "newsco" + ";"
sConnectionStri ng = sConnectionStri ng + "Password=" + "nes0lt12" + ";"
sConnectionStri ng = sConnectionStri ng + "Initial Catalog=" +
"EDIExchang e"

End Sub
Public Sub ConnectToDataba se()

'************** *************** *************** *****
' CONNECT TO THE DATABASE
'************** *************** *************** *****
cnn = New System.Data.Sql Client.SqlConne ction(sConnecti onString)

cnn.Open()

End Sub

End Class

--
Kind Regards
John.
Sep 17 '06 #1
4 1176
Try taking the parameter list out of the main signature - VB doesn't use
that. For capturing the command line arguments use
Microsoft.Visua lBasic.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_Watch er'.

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 gSQLCommandBuil der As System.Data.Sql Client.SqlComma ndBuilder
Dim gDataAdapter As System.Data.Sql Client.SqlDataA dapter
Dim gCurrentExample As Integer

Private sDatabase As String
Private sServer As String
Private sUserID As String
Private sPassword As String
Private sConnectionStri ng As String
Private cnn As System.Data.Sql Client.SqlConne ction
Private cmd As System.Data.Sql Client.SqlComma nd

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("S cripting.FileSy stemObject")

ScriptTimeout = 9999
'##### DEBUGGING SWITCH #####
DebugFlag =
System.Configu ration.Configur ationSettings.A ppSettings("Deb ug")
Dim strDebug As String
If DebugFlag = True Then strDebug = "Debug_"
'############## #############

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

'#### Path is read from app.config file. ####
Source_Dir =
System.Configu ration.Configur ationSettings.A ppSettings(strD ebug &
"SourcePath" )
'############## #### Change Path HERE ############### ###########

MyFolder = MyFileObject.Ge tFolder(Source_ Dir)
Folder = MyFileObject.ge tfolder(MyFolde r)
FileColl = CurrentFolder.F iles

Dim dFolder As DirectoryInfo = New DirectoryInfo(F older.path)
Dim fFileArray() As FileInfo = dFolder.GetFile s
' '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, filelastmodifie d and filesize to SP
'to check if file has changed since last program execution.
strDbInfo = SimpleStoredPro cedurewithArgum ents(fFile.Name )

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

Public Function SimpleStoredPro cedurewithArgum ents(ByVal Parameter As
String) As String

Try

Dim sStoredProcedur e As String
Dim dr As System.Data.Sql Client.SqlDataR eader
Dim pr As System.Data.Sql Client.SqlParam eter
Dim sResults As String

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

BuildConnection String()
ConnectToDataba se()

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

sStoredProcedur e = "SimpleStoredPr ocedurewithArgu ments"

cmd = New System.Data.Sql Client.SqlComma nd(sStoredProce dure, cnn)
cmd.CommandType = System.Data.Com mandType.Stored Procedure

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

pr = cmd.Parameters. Add("@LogFileNa me",
System.Data.Sq lDbType.VarChar , 50)
pr.Direction = System.Data.Par ameterDirection .Input

pr.Value = Parameter + "%"

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

dr = cmd.ExecuteRead er()

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

sResults = "LogFileNam e" + vbTab + "LogFileDat e" + vbTab + vbTab
+ "LogLastModifie d" + vbCrLf + vbCrLf + "LogFileSiz e"

While dr.Read()

sResults = sResults + dr.Item("LogFil eName") + vbTab + vbTab
sResults = sResults + dr.Item("LogFil eDate") + vbTab + vbTab
sResults = sResults + dr.Item("LogLas tModified") + vbTab +
vbTab
sResults = sResults + dr.Item("LogFil eSize") + vbTab

End While

dr.Close()

Return sResults

Catch GetError As System.Exceptio n

End Try

End Function

Public Function SimpleStoredPro cedureMultipleR esults() As String

Try

Dim sStoredProcedur e As String
Dim dr As System.Data.Sql Client.SqlDataR eader
Dim sResults As String
Dim bNextResult As Boolean
Dim iFields As Integer
Dim iFieldAt As Integer

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

BuildConnection String()
ConnectToDataba se()

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

sStoredProcedur e = "SimpleStoredPr ocedureMultiple Results"

cmd = New System.Data.Sql Client.SqlComma nd(sStoredProce dure, cnn)
cmd.CommandType = System.Data.Com mandType.Stored Procedure

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

dr = cmd.ExecuteRead er()

'************** *************** ***********
' 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(iF ieldAt)) + 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.Exceptio n

End Try

End Function

Public Sub BuildConnection String()

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

End Sub
Public Sub ConnectToDataba se()

'************** *************** *************** *****
' CONNECT TO THE DATABASE
'************** *************** *************** *****
cnn = New System.Data.Sql Client.SqlConne ction(sConnecti onString)

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************ ******@discussi ons.microsoft.c omschreef in bericht
news:C2******** *************** ***********@mic rosoft.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_Watche r'.

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 gSQLCommandBuil der As System.Data.Sql Client.SqlComma ndBuilder
Dim gDataAdapter As System.Data.Sql Client.SqlDataA dapter
Dim gCurrentExample As Integer

Private sDatabase As String
Private sServer As String
Private sUserID As String
Private sPassword As String
Private sConnectionStri ng As String
Private cnn As System.Data.Sql Client.SqlConne ction
Private cmd As System.Data.Sql Client.SqlComma nd

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("S cripting.FileSy stemObject")

ScriptTimeout = 9999
'##### DEBUGGING SWITCH #####
DebugFlag =
System.Configur ation.Configura tionSettings.Ap pSettings("Debu g")
Dim strDebug As String
If DebugFlag = True Then strDebug = "Debug_"
'############## #############

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

'#### Path is read from app.config file. ####
Source_Dir =
System.Configur ation.Configura tionSettings.Ap pSettings(strDe bug &
"SourcePath ")
'############## #### Change Path HERE ############### ###########

MyFolder = MyFileObject.Ge tFolder(Source_ Dir)
Folder = MyFileObject.ge tfolder(MyFolde r)
FileColl = CurrentFolder.F iles

Dim dFolder As DirectoryInfo = New DirectoryInfo(F older.path)
Dim fFileArray() As FileInfo = dFolder.GetFile s
' '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, filelastmodifie d and filesize to SP
'to check if file has changed since last program execution.
strDbInfo = SimpleStoredPro cedurewithArgum ents(fFile.Name )

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

Public Function SimpleStoredPro cedurewithArgum ents(ByVal Parameter As
String) As String

Try

Dim sStoredProcedur e As String
Dim dr As System.Data.Sql Client.SqlDataR eader
Dim pr As System.Data.Sql Client.SqlParam eter
Dim sResults As String

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

BuildConnection String()
ConnectToDataba se()

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

sStoredProcedur e = "SimpleStoredPr ocedurewithArgu ments"

cmd = New System.Data.Sql Client.SqlComma nd(sStoredProce dure,
cnn)
cmd.CommandType = System.Data.Com mandType.Stored Procedure

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

pr = cmd.Parameters. Add("@LogFileNa me",
System.Data.Sql DbType.VarChar, 50)
pr.Direction = System.Data.Par ameterDirection .Input

pr.Value = Parameter + "%"

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

dr = cmd.ExecuteRead er()

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

sResults = "LogFileNam e" + vbTab + "LogFileDat e" + vbTab +
vbTab
+ "LogLastModifie d" + vbCrLf + vbCrLf + "LogFileSiz e"

While dr.Read()

sResults = sResults + dr.Item("LogFil eName") + vbTab +
vbTab
sResults = sResults + dr.Item("LogFil eDate") + vbTab +
vbTab
sResults = sResults + dr.Item("LogLas tModified") + vbTab +
vbTab
sResults = sResults + dr.Item("LogFil eSize") + vbTab

End While

dr.Close()

Return sResults

Catch GetError As System.Exceptio n

End Try

End Function

Public Function SimpleStoredPro cedureMultipleR esults() As String

Try

Dim sStoredProcedur e As String
Dim dr As System.Data.Sql Client.SqlDataR eader
Dim sResults As String
Dim bNextResult As Boolean
Dim iFields As Integer
Dim iFieldAt As Integer

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

BuildConnection String()
ConnectToDataba se()

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

sStoredProcedur e = "SimpleStoredPr ocedureMultiple Results"

cmd = New System.Data.Sql Client.SqlComma nd(sStoredProce dure,
cnn)
cmd.CommandType = System.Data.Com mandType.Stored Procedure

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

dr = cmd.ExecuteRead er()

'************** *************** ***********
' 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(iF ieldAt)) +
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.Exceptio n

End Try

End Function

Public Sub BuildConnection String()

'************** *************** *************** *****
' BUILD THE CONNECTION STRING
'************** *************** *************** *****
sConnectionStri ng = "SERVER=" + "(local)" + ";"
sConnectionStri ng = sConnectionStri ng + "User ID=" + "newsco" + ";"
sConnectionStri ng = sConnectionStri ng + "Password=" + "nes0lt12" +
";"
sConnectionStri ng = sConnectionStri ng + "Initial Catalog=" +
"EDIExchang e"

End Sub
Public Sub ConnectToDataba se()

'************** *************** *************** *****
' CONNECT TO THE DATABASE
'************** *************** *************** *****
cnn = New System.Data.Sql Client.SqlConne ction(sConnecti onString)

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************ ******@discussi ons.microsoft.c omschreef in bericht
news:C2******** *************** ***********@mic rosoft.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_Watche r'.

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 gSQLCommandBuil der As System.Data.Sql Client.SqlComma ndBuilder
Dim gDataAdapter As System.Data.Sql Client.SqlDataA dapter
Dim gCurrentExample As Integer

Private sDatabase As String
Private sServer As String
Private sUserID As String
Private sPassword As String
Private sConnectionStri ng As String
Private cnn As System.Data.Sql Client.SqlConne ction
Private cmd As System.Data.Sql Client.SqlComma nd

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("S cripting.FileSy stemObject")

ScriptTimeout = 9999
'##### DEBUGGING SWITCH #####
DebugFlag =
System.Configur ation.Configura tionSettings.Ap pSettings("Debu g")
Dim strDebug As String
If DebugFlag = True Then strDebug = "Debug_"
'############## #############

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

'#### Path is read from app.config file. ####
Source_Dir =
System.Configur ation.Configura tionSettings.Ap pSettings(strDe bug &
"SourcePath ")
'############## #### Change Path HERE ############### ###########

MyFolder = MyFileObject.Ge tFolder(Source_ Dir)
Folder = MyFileObject.ge tfolder(MyFolde r)
FileColl = CurrentFolder.F iles

Dim dFolder As DirectoryInfo = New DirectoryInfo(F older.path)
Dim fFileArray() As FileInfo = dFolder.GetFile s
' '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, filelastmodifie d and filesize to SP
'to check if file has changed since last program execution.
strDbInfo = SimpleStoredPro cedurewithArgum ents(fFile.Name )

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

Public Function SimpleStoredPro cedurewithArgum ents(ByVal Parameter As
String) As String

Try

Dim sStoredProcedur e As String
Dim dr As System.Data.Sql Client.SqlDataR eader
Dim pr As System.Data.Sql Client.SqlParam eter
Dim sResults As String

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

BuildConnection String()
ConnectToDataba se()

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

sStoredProcedur e = "SimpleStoredPr ocedurewithArgu ments"

cmd = New System.Data.Sql Client.SqlComma nd(sStoredProce dure,
cnn)
cmd.CommandType = System.Data.Com mandType.Stored Procedure

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

pr = cmd.Parameters. Add("@LogFileNa me",
System.Data.Sql DbType.VarChar, 50)
pr.Direction = System.Data.Par ameterDirection .Input

pr.Value = Parameter + "%"

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

dr = cmd.ExecuteRead er()

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

sResults = "LogFileNam e" + vbTab + "LogFileDat e" + vbTab +
vbTab
+ "LogLastModifie d" + vbCrLf + vbCrLf + "LogFileSiz e"

While dr.Read()

sResults = sResults + dr.Item("LogFil eName") + vbTab +
vbTab
sResults = sResults + dr.Item("LogFil eDate") + vbTab +
vbTab
sResults = sResults + dr.Item("LogLas tModified") + vbTab +
vbTab
sResults = sResults + dr.Item("LogFil eSize") + vbTab

End While

dr.Close()

Return sResults

Catch GetError As System.Exceptio n

End Try

End Function

Public Function SimpleStoredPro cedureMultipleR esults() As String

Try

Dim sStoredProcedur e As String
Dim dr As System.Data.Sql Client.SqlDataR eader
Dim sResults As String
Dim bNextResult As Boolean
Dim iFields As Integer
Dim iFieldAt As Integer

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

BuildConnection String()
ConnectToDataba se()

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

sStoredProcedur e = "SimpleStoredPr ocedureMultiple Results"

cmd = New System.Data.Sql Client.SqlComma nd(sStoredProce dure,
cnn)
cmd.CommandType = System.Data.Com mandType.Stored Procedure

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

dr = cmd.ExecuteRead er()

'************** *************** ***********
' 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(iF ieldAt)) +
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
1984
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 possible to have a project that accepts both kind of sources? I mean for example one class is in VB.NET and the other in C#. Then one can trace or debug a mixed code that switches between several languages code. In general when I want to create a...
7
5783
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 planning to convert this project to dot net sometime in the future. Our architecture is an exe project with references to four business object dlls. Also, each one of our tables is encapsulated in a data object dll. The data objects are referenced...
3
317
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 possible to have a project that accepts both kind of sources? I mean for example one class is in VB.NET and the other in C#. Then one can trace or debug a mixed code that switches between several languages code. In general when I want to create a...
49
3908
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 isomorphism between filesystem and namespace, doesn't seem very well suited for big projects. However, I might not really understand the Pythonic way. I'm not sure if I have a specific question here, just a general plea for advice. 1) Namespace....
0
8009
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7939
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8432
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8078
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8299
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5962
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3919
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1548
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1285
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.