Link to home
Start Free TrialLog in
Avatar of joanne84
joanne84

asked on

How to change to .exe file?

Hi expert,

Currently I'm using Microsoft Visual Studio.Net to program an application.
Now I need to run the application in scheduler task.
May I know to change the program so that it can run as .exe file?
Thanx.

Regards,
Joanne84
Avatar of guidway
guidway
Flag of United States of America image

when you compile your project it should create the executable automatically. You may need to search for the name of it on the computer. If you have errors during the compile it will not create the executable until they are all fixed.
Avatar of joanne84
joanne84

ASKER

Hi,

The compilation is error free.
But how can I find the .exe file?

Is it namely filename.exe?

Please advise.
Thanx.

Regards,
joanne84
Hi Joanne84,

The name is usually the project name.  It is in *bold* letters in the solution explorer window.

You can find the executable in the "bin" directory in your project folder.



hec",)
<ProjectDirectory> \ bin \ 'debug' or 'release'
Hi,

The schedule task still show me the status: Could Not Start...

For ur information, the scheduler that I want to run is scheduler.aspx, which is inside a project namely, Seminar. I can only found Seminar.pdb and Seminar.dll in the bin folder.

I tried to run both file, also cannot. Do I need to create a new project name Scheduler instead?
Otherwise, please advise.

Thanx.

Regards,
joanne84
ASKER CERTIFIED SOLUTION
Avatar of dapcom
dapcom
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I get what you mean.
So, now I've created a window application.
And I copied the coding in .aspx to the window application.

Where  should I put the db connection as in web application, we put it in web.config?

It shows a break point at       
dr = myCommand.ExecuteReader();

An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll
Additional information: The ConnectionString property has not been initialized.

I still fresh to .net, so sorry for my poor understanding...

Regards,
joanne84

To start, just put it in your code:
    Dim myConnectionString as String = "Your connection string"
    Dim myConnection As New SqlConnection(myConnectionString)
    Dim myCommand As New SqlCommand(mySelectQuery, myConnection)
    dr = myCommand.ExecuteReader();

when it works, create an application.config file in the same folder as the exe, same name, but extension .config:
<configuration>
   <appSettings>
      <add key="ConnectionString" value="type your connection string here" />
   </appSettings>
</configuration>

Then use the ConfigurationSettings class to replace the hardcoded connection string.

myConnectionString=ConfigurationSettings.AppSettings("ConnectionString")

(you can have a look at : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vboriintroductiontoapplicationsettingstorage.asp)

Dan
Hi Dan,

For your info, I'm using C#...
I've created a Form1.config to put the database configuration, but the previous error still occur...

To have clear idea of my project, below are some of the code:

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

private void button1_Click(object sender, System.EventArgs e)
{      this.Close ();      }
public Form1()
{      InitializeComponent();
      Run();
}

In the Run(), I retrieve information from a userclass, which return datareader, dr.

It shows a break point at      
dr = myCommand.ExecuteReader();   //Occur in the user class file

Do you have any solution?
Thanx in advance.

joanne84
Hi joanne84,

Thanks for the points :)

Your file should have the name of the application, not the form. In your case I think it is Seminar.config and must be in the same directory as your exe (in bin).

Did you translate the code i gave you in C# or do you need help for that?
Do you have the same error message?
It seems the connection string is not set. You must retrieve it with the

ConfigurationSettings.AppSettings("ConnectionString")

The easiest would be if you send the code of the Run() procedure (or the relevent part of it, around the error), so I can have a look at it.



Dan

Hi Dan,

Thanx for your help.
I already solved the problem.

Actually, I just need to create a console application, then use a web client to call the URL of the file that I want it to run, for this case is Scheduler.aspx.

Then in the scheduler task, I call the console application's application file, then can already.

Thanx:-)

Regards,
joanne84