Forums - C# Corner

Forum guidelines


  • 1.3k
  • 9
  • 3.3k

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; 
  /// The main entry point for the application.

  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)

Unlimited Flat-Free License


File APIs for .NET
Aspose are the market leader of .NET APIs for file business formats – natively work with DOCX, XLSX, PPT, PDF, MSG, MPP, images formats and many more!