| |

VerySource

 Forgot password?
 Register
Search
View: 676|Reply: 3

A question about DateSet

[Copy link]

1

Threads

7

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-20 00:40:01
| Show all posts |Read mode
/ * On the other hand, the DataSet class was originally designed to establish relationships between data tables.
* The code in this section shows how to manually generate and populate two data tables. If you do not have SQL Server or North Wind database
* You can run this example
* /
DataSet ds = new DataSet ("Relationships");
ds.Tables.Add (CreateBuildingTable ());
ds.Tables.Add (CreateRoomTable ());
ds.Relations.Add ("Rooms", ds.Tables ["Building"]. Columns ["BuildingID"], ds.Tables ["Room"]. Columns ["BuildingID"]);
Error 1 The name "CreateBuildingTable" does not exist in the current context
Error 2 The name "CreateRoomTable" does not exist in the current context

Doesn't this example say to manually generate 2 DataTables in a DataSet
What went wrong? Thank you for your kind suggestion
Reply

Use magic Report

1

Threads

26

Posts

14.00

Credits

Newbie

Rank: 1

Credits
14.00

 China

Post time: 2020-1-28 12:45:01
| Show all posts
"CreateBuildingTable"
"CreateRoomTable"
These are the two functions that create a table. If you don't define it, you will of course make mistakes!
You can define it as follows:
private System.Data.DataTable CreateBuildingTable ()
{
    System.Data.DataTable dtRet = new System.Data.DataTable ("Building");
    dtRet.Columns.Add (new System.Data.DataColumn ("BuildingID", System.Type.GetType ("System.Int32"));
    // and so on, add the remaining columns
    return dtRet;
}

private System.Data.DataTable CreateRoomTable ()
{
    System.Data.DataTable dtRet = new System.Data.DataTable ("Building");
    dtRet.Columns.Add (new System.Data.DataColumn ("BuildingID", System.Type.GetType ("System.Int32"));
    // and so on, add the remaining columns
    return dtRet;
}
Reply

Use magic Report

0

Threads

52

Posts

34.00

Credits

Newbie

Rank: 1

Credits
34.00

 China

Post time: 2020-1-28 13:09:01
| Show all posts
CreateBuildingTable ()
CreateRoomTable ()
Are two methods
Reply

Use magic Report

1

Threads

26

Posts

14.00

Credits

Newbie

Rank: 1

Credits
14.00

 China

Post time: 2020-1-28 14:18:01
| Show all posts
Change Building in the second to Room!
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list