Home All Groups Group Topic Archive Search About

Newbee - Project with single module.

Author
17 Sep 2006 8:29 PM
John please don't spam me!
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.AppSettings("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.AppSettings(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(sConnectionString)

        cnn.Open()

    End Sub

End Class

--
Kind Regards
John.

Author
17 Sep 2006 11:23 PM
tomb
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:

Show quoteHide quote
>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.AppSettings("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.AppSettings(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(sConnectionString)
>
>        cnn.Open()
>
>    End Sub
>
>End Class
>

>
Author
18 Sep 2006 4:17 AM
Cor Ligthert [MVP]
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!"
<Johnpleasedontspamme@discussions.microsoft.com> schreef in bericht
Show quoteHide quote
news:C24842C4-73E0-4BC6-B92D-4A75B94DC848@microsoft.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.AppSettings("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.AppSettings(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(sConnectionString)
>
>        cnn.Open()
>
>    End Sub
>
> End Class
>
> --
> Kind Regards
> John.
Author
19 Sep 2006 8:23 PM
John please don't spam me!
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.


Show quoteHide quote
"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!"
> <Johnpleasedontspamme@discussions.microsoft.com> schreef in bericht
> news:C24842C4-73E0-4BC6-B92D-4A75B94DC848@microsoft.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.AppSettings("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.AppSettings(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
> >
Author
20 Sep 2006 3:48 AM
Cor Ligthert [MVP]
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