OLEDB DataShape Provider For SQL Server

Following is a connection string that enables DataShaping

string strConnectionString =  “Provider=MSDataShape;Data Provider=SQLOLEDB;Data Source=mySQLServerName;” +
                                                “Initial Catalog=myDatabase;User ID=myUsername;Password=myPassword”;

After making a successful connection you can fire following query to create a hierarchical record set

string strSQL = “SHAPE{Select <column1>,<column2>,… From <Table> Where <Conditions>} “+

                             ”  APPEND({Select <column1>,<column2>,… From <Table> Where <Conditions>} AS <Child Name> “+

                             ” RELATE  <PrimaryKey> TO <ForeignKey>)”;

Advertisements