console-application

Must declare the table variable @table

不想你离开。 提交于 2019-11-27 15:13:40
I'm a beginner in C# and SQL, i have this SQL insert statement that i want to perform. It asks for the table name among the other variables that i want to insert. But when i run this console app i get this error : Must declare the table variable @table This is a part of the code : StreamReader my_reader = getFile(args); string CS = formCS(); try { using (SqlConnection con = new SqlConnection(CS)) { SqlCommand com = new SqlCommand("insert into @table (time, date, pin) values (@time, @date, @pin)", con); con.Open(); Console.WriteLine("Enter table name:"); Console.Write(">> "); string tblname =

Clear Console Buffer

荒凉一梦 提交于 2019-11-27 14:54:32
问题 I'm writing a sample console application in VS2008. Now I have a Console.WriteLine() method which displays output on the screen and then there is Console.ReadKey() which waits for the user to end the application. If I press Enter while the Console.WriteLine() method is displaying then the application exits. How can I clear the input buffer before the Console.ReadKey() method so that no matter how many times the user presses the Enter button while the data is being displayed, the Console

How to create ASCII animation in a console application using Python 3.x?

走远了吗. 提交于 2019-11-27 14:12:47
问题 I would like to port this question to Python (Windows + Linux + Mac Os) How to create ASCII animation in Windows Console application using C#? Thank you! 回答1: I just ported my example with the animated gif to ASCII animation from my answer here to python. You will need to install the pyglet library from here, as python unfortunately has no built-in animated-gif support. Hope you like it :) import pyglet, sys, os, time def animgif_to_ASCII_animation(animated_gif_path): # map greyscale to

Console App Mouse-Click X Y Coordinate Detection/Comparison

天涯浪子 提交于 2019-11-27 14:08:43
I have a game that I am working on in a C# console application, purely as practice before going on to better methods. As opposed to using something such as a Windows Forms App, which has button functionality built in, I am endeavoring to grab the cursor position (which I know how to do) and compare it to a number of area's inside a console application as defined by perhaps pixel location, but I also do not know if there is some sort of built in unit of space other than pixels (this last bit is the part I am unable to figure). P.S. I know this is in general terms, with no code already provided,

How do I compile my App.config into my exe in a VS2010 C# console app?

佐手、 提交于 2019-11-27 13:54:16
I'm creating a console app in Visual Studio 2010 with c#. I want this app to be stand alone, in that all you need is the exe, and you can run it from anywhere. I also want to use app.config to store connection strings and so on. My problem is that I can't seem to figure out how to include that app.config data into the compiled exe. I do see it creates appname.exe.config, but I don't want people to have to worry about grabbing two separate files when they get the app. None of the googling I've done has come up with anything. Is this even possible? You can't. Half the point of such config files

When should one use Environment.Exit to terminate a console application?

送分小仙女□ 提交于 2019-11-27 13:53:22
I'm maintaining a number of console applications at work and one thing I've been noticing in a number of them is that they call Environment.Exit(0). A sample program would look like this: public class Program { public static void Main(string[] args) { DoStuff(); Environment.Exit(0); } } I don't understand what the intent of the original programmer was in doing this? In my mind even without the Environment.Exit statement the program should exit just fine. That said, for one of these programs, it's console window has been remaining even after it was supposed to have closed so I'm really not sure

Is Thread.Sleep(Timeout.Infinite); more efficient than while(true){}?

泪湿孤枕 提交于 2019-11-27 13:33:56
问题 I have a console application that I would like to keep open all of the time while still listening in to events. I have tested Thread.Sleep(Timeout.Infinite); and while (true) { } and both allow the events to be raised while keeping the console application open. Is there one that I should be using over the other? If the thread is sleeping, is there anything that I should not be doing, such as modifying a static collection declared in the scope of the class? 回答1: I would recommend using a

Redirect Console.Write… Methods to Visual Studio's Output Window While Debugging

浪尽此生 提交于 2019-11-27 13:28:34
From a Console Application project in Visual Studio , I want to redirect Console 's output to the Output Window while debugging. Change application type to Windows before debugging. Without Console window, Console.WriteLine works like Trace.WriteLine. Don't forget to reset application back to Console type after debugging. class DebugWriter : TextWriter { public override void WriteLine(string value) { Debug.WriteLine(value); base.WriteLine(value); } public override void Write(string value) { Debug.Write(value); base.Write(value); } public override Encoding Encoding { get { return Encoding

How can a C# Windows Console application tell if it is run interactively

半腔热情 提交于 2019-11-27 12:44:04
How can a Windows console application written in C# determine whether it is invoked in a non-interactive environment (e.g. from a service or as a scheduled task) or from an environment capable of user-interaction (e.g. Command Prompt or PowerShell)? Environment.UserInteractive Property To determine if a .NET application is running in GUI mode: bool is_console_app = Console.OpenStandardInput(1) != Stream.Null; I haven't tested it, but Environment.UserInteractive looks promising. If all you're trying to do is to determine whether the console will continue to exist after your program exits (so

Compile to a stand-alone executable (.exe) in Visual Studio

ぐ巨炮叔叔 提交于 2019-11-27 12:19:47
how can I make a stand-alone exe in Visual Studio. Its just a simple Console application that I think users would not like to install a tiny Console application. I compiled a simple cpp file using the visual studio command prompt. Will the exe work even if the .NET framework is not installed? I used native C++ code. Anything using the managed environment (which includes anything written in C# and VB.NET) requires the .NET framework. You can simply redistribute your .EXE in that scenario, but they'll need to install the appropriate framework if they don't already have it. Inside your project