locked
Generic Methods RRS feed

  • Question

  • User1037983650 posted

    Hey Developers ..

    I just want to write a code once to save records in multiple tables ... I want to implement Generic Methods .I have three .aspx pages where I require to save data in three different tables ...Please forward me complete steps. .please forward c# code only ..Thanks 

    Saturday, May 25, 2013 5:59 AM

All replies

  • User-541184106 posted

    Hi,

         The best way to run insert query on multiple tables is to use Transaction Scope, If any table query fails to insert then transaction scope immediately rollbacks other queries too. have a look on below article

    http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx

     

    Saturday, May 25, 2013 7:09 AM
  • User1320101480 posted

    Please forward me complete steps?

    Did you try writing a Generic method, are you facing any problems?

    Sunday, May 26, 2013 11:05 AM
  • User1037983650 posted

    I am going to write a generic method to save data in multiple tables ( Not at a same time ) ..so plz forward me complete code ..

    Wednesday, May 29, 2013 11:38 AM
  • User1037983650 posted

    Hey developers ..Let me simplify my query by considering an scenario. 

    Suppose we have a three tables with different number of columns . . we want to save records to those three tables but at different instant of time. . What i want to write the logic to save record only once .( in class file ) . it should be using generic method and also be able to open the connection with database server( SQLServer 2008) .. I want to pass number of parameters in .aspx.cs file .. . 

    Hope you understant my problem ..

    Please write me back as soon as possible .

    Sunday, June 9, 2013 1:10 AM
  • User1109032460 posted

    sukhdeep_kambo

    I am going to write a generic method to save data in multiple tables ( Not at a same time ) ..so plz forward me complete code ..

    Just as a matter of interest, what is the hourly rate that you're paying for doing your work for you?

    How about trying this instead: you write some code; we'll help you fix it when you have a problem.

    To get you started, though, I'll give you some code

    public void UpdateDataToMultipleTables<T>()
    {
    }

    There. A nice, generic method for you to get going with. 

    Thursday, June 20, 2013 6:06 PM