C# SQL Console Application

run database using console application

Page 1 of 1

3 Replies - 4519 Views - Last Post: 18 August 2009 - 10:49 PM Rate Topic: -----

#1 dunk_6  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 43
  • Joined: 03-August 09

C# SQL Console Application

Posted 17 August 2009 - 03:08 AM

I'm not very familiar with the console application but i think its kind a interesting subject to learned. I searched for tutorials and references related to connecting MySQL database with console application but no luck. So i just try and error. Please correct me I'm wrong..

I had an application where when user run the program, it'll store values to database. In the Form Application, it runs well(no doubt). Now with the same approach, i want it to be run it in the console application. So, I create new project in console and just copy, do some editing on the codes and put in Main. Luckily, the code running well.

My concerns are, is it what i'm doing is write? the command for the form can be used in console? What are differences between this two? is this the better approached?

Any advice and references are very helpful.


Is This A Good Question/Topic? 0
  • +

Replies To: C# SQL Console Application

#2 SwiftStriker00  Icon User is offline

  • Microsoft Insider
  • member icon

Reputation: 432
  • View blog
  • Posts: 1,596
  • Joined: 25-December 08

Re: C# SQL Console Application

Posted 17 August 2009 - 05:13 AM

Well the difference between a form and console for a user is just how you go about input. A form, you can have a 'insert' button, a 'input' textfield, and a drop down menu, for available tables, and one for column. The user just has to enter the value, and pick a table and column, and hit insert! Voila.

now in a console, which prefered by tech savy people, allows for more options without taking up space of static form components, but requires your users to know a bit more whats going on. I say you have 2 choices when it comes to this method. First if you want to be more rigid and simplistic for your users I would create a series of menu options for the user to go through to get to the desired result. A work flow of your program could look like this:

Quote

SQL Program, enter a valid command or ? for a list of commands
> ?
Availible commands: INSERT, DELETE, JOIN, EXIT
> INSERT
Insert what value?
> 9001
Thanks, what Table is this going in?
> tbl.Awesome
Ok, and what column?
> powerLevel
...Done!


Now if your user are a bit more advanced, you can just create availible commands with parameters (something that you will probably have for the back end of the previous way, just this time you let your users do it)
>INSERT 9001 "tbl.Awesome" "powerlevel"

Now did this help or did I confuse you?
Was This Post Helpful? 0
  • +
  • -

#3 dunk_6  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 43
  • Joined: 03-August 09

Re: C# SQL Console Application

Posted 18 August 2009 - 09:43 PM

Ooooh, that's mean, the differences between this applications is UI concerned. But how bout the codes writing? is it totally similar or different.

Based on your quote, how you run this SQL program. It's directly you open n write in console or by first running some sort of c# application?
Was This Post Helpful? 0
  • +
  • -

#4 SwiftStriker00  Icon User is offline

  • Microsoft Insider
  • member icon

Reputation: 432
  • View blog
  • Posts: 1,596
  • Joined: 25-December 08

Re: C# SQL Console Application

Posted 18 August 2009 - 10:49 PM

If you design your code properly, there should be very little needed to be changed when consdering GUI vs Console. The reason being, you should develop your code in two parts UI and Backend. Your backend is your functionality, and the UI is how your user accesses that functionality. So if you have a selectTable() method and it returns a string that has the table name. The prefered difference would be:
Console.WriteLine( " Table {0} retrieved", selectTable() ); and
resultTextField.Text = selectTable();
All in all, what is more efficient for your users to use. and w/ something like sql, i'd say you have more flexibility w/ Console, and i would go for that.

for your second question; you would write the C# application to oupt a menu and a prompt, process the prompt (backend would do whatever sql it needs to), display the results, and loop back to a menu again. Thats if they will be doing more than one task. If they are only going to do just 1 or 2 things then you can also design the c# exe to take in parameters in the command prompt. So you have options on how you want to make it

This post has been edited by SwiftStriker00: 18 August 2009 - 10:49 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1