Windows Application

  • Thread starter Thread starter joseph
  • Start date Start date
J

joseph

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.
 
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
 
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());
}
 
I searched for New() event in the .Net help file and no

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
 
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.
 
If you have some working ADO.Net program to connect to Access
2000 database and add,edit and delete records please post
it.

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.OleDb

Module Module1

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

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

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

cn.Open()

cmd.ExecuteNonQuery()

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

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

Hope this helps,

Chris
 
Back
Top