none
Equivalent Sql Queries of Some Ado.net methods RRS feed

  • Question

  • OK. I used to cretae relation between datatables in datasets. It is disconnected layer. The code was:

     

     

     

    // Create CustomerOrder data relation object.
    
                 DataRelation dr = new DataRelation("CustomerOrder",
    
                     autoLotDS.Tables["Customers"].Columns["CustID"],
    
                     autoLotDS.Tables["Orders"].Columns["CustID"]);
    
                 autoLotDS.Relations.Add(dr);
    
    
    
    
    DataRow[] drsCust = null;
    
                DataRow[] drsOrder = null;
    
    
    
                // Get the customer ID in the text box.
    
                int custID = int.Parse(this.txtCustID.Text);
    
    
    
                // Now based on custID, get the correct row in Customers Table.
    
                drsCust = autoLotDS.Tables["Customers"].Select(
    
                    string.Format("CustID = {0}", custID));
    
    
    
     // Navigate from Customers table to Orders table.
    
                drsOrder = drsCust[0].GetChildRows(autoLotDS.Relations["CustomerOrder"]);
    

    And now i have a program and I create SQL database and tables in runtime, programmatically.

    And i want to create parent/child ralation between them. Which query i need?

     

    Thanks.

     

     

     

     

     

     

     


    MICROSOFT
    Thursday, August 18, 2011 2:48 PM

Answers

  • no no. All i needed was Inner Join. Thanks. Just I thought that there must be equivalent queries with the all ADO.net methods. So, my brain was a little bit confused.
    Assassin's Creed: Nothing is True, Everything is Permitted.
    • Marked as answer by Ferhad Cebiyev Wednesday, August 24, 2011 9:06 AM
    Friday, August 19, 2011 11:47 AM

All replies

  • I am not sure about the question. Are you asking how to create a foreign relation in database at runtime from your application?
    Miha Markic [MVP C#] http://blog.rthand.com
    Friday, August 19, 2011 11:12 AM
  • no no. All i needed was Inner Join. Thanks. Just I thought that there must be equivalent queries with the all ADO.net methods. So, my brain was a little bit confused.
    Assassin's Creed: Nothing is True, Everything is Permitted.
    • Marked as answer by Ferhad Cebiyev Wednesday, August 24, 2011 9:06 AM
    Friday, August 19, 2011 11:47 AM
  • access records in the related datatables, you just check this link http://msdn.microsoft.com/en-us/library/ms171913.aspx it looks that your code is good. But i didn't also sure about your concern. you want to use Inner Join to relate two datatables? or others? but i dont think it equals with ado.net. datatable was the momery level, perhaps you should fetch the data from the database. but what's your concern on earth?

    Thanks,

    Werewolf,


    Just a newbie for everything.
    Monday, August 22, 2011 6:52 AM
  • i used taht in ADO.net disconnected layer. And then i think that it will be good if i will do same in connected layer.  I get same result with Inner Join.
    Assassin's Creed: Nothing is True, Everything is Permitted.
    Monday, August 22, 2011 7:14 AM
  • OK Ferhad, I have a little confusion for your question. At your first thread, you said you want to create parent/child relation. but you rejected Miha's clarificatioin. Then, you want to use Inner join, but you also said it didn't work still. My question was, can you tell us your exact need? :)

    Thanks,

    Werewolf,


    Just a newbie for everything.
    Tuesday, August 23, 2011 8:00 AM
  • :)) No. no. May be due to my poor English, i didn't write what i want.  I read a book about C#2010 and .net 4. In that book I learn to create relation between tables in Dataset in Ado.net Disconnected layer.

    Then i try to create relation between tables in upright Sql database  by using Ado.net  Connected layer. And I can do it visually in Sql Server or VS2010. But i wanted to create it in runtime, programmatically. Because i needed to get some parent or child rows in runtime. But, actually,  i didn't need smth other than Inner Join. I can get parent or child rows with Inner Join statement. So we can say that this thread is unnecessary to other people. Also for me.  )))))   I look up for deleting thread, but i didn't find delete option.


    Assassin's Creed: Nothing is True, Everything is Permitted.


    Tuesday, August 23, 2011 8:51 AM
  • Hello Ferhad,

    It looks that you have already solved your question. If yes, I suggest you can mark helpful replies as Answer preferred. It's benefit very much from your case. I think it helps other members to enlighten their experience.

    Please feel free to let us know if you need further support.

    Thanks,


    Larcolais Gong[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, August 24, 2011 8:56 AM