c# - how to call method multiple time on button click -
i have code below allow me add data excel sheet directly sing given database, know how able call method multiple times add data 2 different excel file @ once, button calls method once clicked, using multi-threading.
private void addtodatabase() { using (oledbconnection connection = new oledbconnection(excelconnectionstring)) { connection.open(); checknumeberofsheets(connection); } } button code;
private void button1_click(object sender, eventargs e) { addtodatabase(); }
may can pass string method addtodatabse like
private void addtodatabase(string filename){ if(filename.equals("yourfirstfile")) { using (oledbconnection connection = new oledbconnection(excelconnectionstring)) { connection.open(); checknumeberofsheets(connection); } } else if(filename.equals("yoursecondfile")) { using (oledbconnection connection = new oledbconnection(excelconnectionstring2)) { connection.open(); checknumeberofsheets(connection); } } } and call this
private void button1_click(object sender, eventargs e) { addtodatabase("yourfirstfile"); addtodatabase("yoursecondfile"); }
Comments
Post a Comment