Forums - C# Corner

Forum guidelines


  • 1.5k
  • 9
  • 3.5k

call the main fuction

Dec 12 2012 7:36 PM
I want to call the Main function of class Program, and pass a sql string to the Main fuction,
from the function of btn1Search_Click of the class Form1, when i click a button on the main form.

i am writing a project for database, and all the data put into the dataGridView. and i want the window displays another data when i click a button.

Could anyone tell me how to do that, please.

  static class Program

  public static string sql; 
  /// <summary>
  /// The main entry point for the application.
  /// </summary>
  static void Main(string[] args)
  if (args.Length < 1)
  sql = "select buyerName, id, category, productName, price, date, referenceNo from elena ";
  sql = args[0];
  Application.Run(new Form1(sql));
  public partial class Form1 : Form
  private void btn1Search_Click(object sender, EventArgs e)



Answers (8)