Windows Application

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • joseph

    Windows Application

    Hi,
    I would like to run a windows application without the user
    interface. Console application is not a choice because it
    does not allow to use ADO controls. When I start the
    Windows Application I do not want to see the Form and
    click some buttons to start a program. The program should
    start executing the main program immediately.

    Thank you very much for help.
  • Tim Stephenson

    #2
    Re: Windows Application

    If you're referring to a .net windows application, you can use ADONet
    controls in console apps - just add a reference to the system.data
    namespace.

    You could also just start your code in the New() or form load event, rather
    than putting it into a button click event handler.

    If the app needs to run in the background, another option would be to take a
    look at windows services.

    --

    Regards

    Tim Stephenson MCSD.NET
    Charted MCAD & MCSD.NET Early Achiever


    "joseph" <cmjoseph@hotma il.com> wrote in message
    news:2738601c38 f3c$9c609190$a6 01280a@phx.gbl. ..[color=blue]
    > Hi,
    > I would like to run a windows application without the user
    > interface. Console application is not a choice because it
    > does not allow to use ADO controls. When I start the
    > Windows Application I do not want to see the Form and
    > click some buttons to start a program. The program should
    > start executing the main program immediately.
    >
    > Thank you very much for help.[/color]


    Comment

    • Joseph

      #3
      Re: Windows Application

      Hi,

      Thank you very much for the quick response.

      The application is .Net Windows Application. This program
      reads a log file and search for previous days information.
      Right now I have to start the application and input the
      date value and click the process button. I want to run
      this program in a batch file and pass the date value as a
      parameter.
      I searched for New() event in the .Net help file and no
      reference can be found. Is this event a Form Event? I do
      not see this event listed in the form property.

      Also Microsoft do not recomment long processing program in
      Form load event. Form load event is usually used to set up
      the environment.

      The question is can I modify the Windows Application main
      program and run a procedure instead of Form.

      static void Main()
      {
      Application.Run (new Form1());
      }

      [color=blue]
      >-----Original Message-----
      >If you're referring to a .net windows application, you[/color]
      can use ADONet[color=blue]
      >controls in console apps - just add a reference to the[/color]
      system.data[color=blue]
      >namespace.
      >
      >You could also just start your code in the New() or form[/color]
      load event, rather[color=blue]
      >than putting it into a button click event handler.
      >
      >If the app needs to run in the background, another option[/color]
      would be to take a[color=blue]
      >look at windows services.
      >
      >--
      >
      >Regards
      >
      >Tim Stephenson MCSD.NET
      >Charted MCAD & MCSD.NET Early Achiever
      >
      >
      >"joseph" <cmjoseph@hotma il.com> wrote in message
      >news:2738601c3 8f3c$9c609190$a 601280a@phx.gbl ...[color=green]
      >> Hi,
      >> I would like to run a windows application without the[/color][/color]
      user[color=blue][color=green]
      >> interface. Console application is not a choice because[/color][/color]
      it[color=blue][color=green]
      >> does not allow to use ADO controls. When I start the
      >> Windows Application I do not want to see the Form and
      >> click some buttons to start a program. The program[/color][/color]
      should[color=blue][color=green]
      >> start executing the main program immediately.
      >>
      >> Thank you very much for help.[/color]
      >
      >
      >.
      >[/color]

      Comment

      • Chris Dunaway

        #4
        Re: Windows Application

        "Joseph" <cmjoseph@hotma il.com> wrote in news:010f01c38f 4b$73d676e0
        $a301280a@phx.g bl:
        [color=blue]
        > I searched for New() event in the .Net help file and no[/color]

        New is the form's constructor. It's not an event.

        As the other poster said, you should be able to use a console application.
        You can use ADO.Net with it just fine. What's stopping you?

        Chris

        Comment

        • Joseph

          #5
          Re: Windows Application

          The problem in using ADO.Net in console application is
          that the Data omponent like OleDataAdapter and
          OleDbConnection are not available to connect to an Access
          2000 database. I got some sample ADO.Net program to
          connect to Access 2000 database, but it does not work. If
          you have some working ADO.Net program to connect to Access
          2000 database and add,edit and delete records please post
          it.
          Thanks.[color=blue]
          >-----Original Message-----
          >"Joseph" <cmjoseph@hotma il.com> wrote in[/color]
          news:010f01c38f 4b$73d676e0[color=blue]
          >$a301280a@phx. gbl:
          >[color=green]
          >> I searched for New() event in the .Net help file and no[/color]
          >
          >New is the form's constructor. It's not an event.
          >
          >As the other poster said, you should be able to use a[/color]
          console application.[color=blue]
          >You can use ADO.Net with it just fine. What's stopping[/color]
          you?[color=blue]
          >
          >Chris
          >.
          >[/color]

          Comment

          • Chris Dunaway

            #6
            Re: Windows Application

            "Joseph" <cmjoseph@hotma il.com> wrote in news:130f01c393 64$b710f3a0
            $a001280a@phx.g bl:
            [color=blue]
            > If you have some working ADO.Net program to connect to Access
            > 2000 database and add,edit and delete records please post
            > it.[/color]

            Here is a *very* small console app that inserts a record into an Access
            table. The access database has one table with three fields named
            "NumberField"," TextField", and "MoneyField ".

            The app takes each value from the command line and updates the table.
            This app doesn't do much but it can connect to an Access database.

            (Watch for line wrapping)


            '\\\\\\\\\\\\\\ \\\
            Imports System.Data.Ole Db

            Module Module1

            Private ConnStr As String = "Provider=Micro soft.Jet.OLEDB. 4.0;" User
            ID=Admin;Data Source=C:\test\ db1.mdb;Mode=Sh are Deny None"

            Sub Main(ByVal CmdArgs() As String)
            Dim cn As New OleDbConnection (ConnStr)
            Dim cmd As New OleDbCommand

            With cmd
            .CommandType = CommandType.Tex t
            .CommandText = "Insert into Table1 (NumberField, TextField,
            MoneyField) " & _
            "VALUES (" & CmdArgs(0) & ",'" & CmdArgs(1) &
            "'," & CmdArgs(2) & ")"
            .Connection = cn
            End With

            cn.Open()

            cmd.ExecuteNonQ uery()

            cn.Close()
            cmd.Dispose()
            cn.Dispose()
            End Sub

            End Module
            ..///////////////////

            Hope this helps,

            Chris

            Comment

            Working...