A sample code to Create a relationship between two tables? A Datarelation represents a relationship between parent and child Datatable. ? The demonstration uses the GetChildRows to return the datarow of child objects for every child datarelation in datatable.[bold]Step 1: main.aspx[/bold]
<!asp:Label id="Label1" style= "Z-INDEX: 102; LEFT: 8px; POSITION: absolute; TOP: 8px" runat="server">Label<!/asp:Label>
[bold]Step 2: main.aspx.vb [/bold ...A sample code to Create a relationship between two tables? A Datarelation represents a relationship between parent and child Datatable. ? The demonstration uses the GetChildRows to return the datarow of child objects for every child datarelation in datatable.[bold]Step 1: main.aspx[/bold]
<asp:Label id="Label1" style= "Z-INDEX: 102; LEFT: 8px; POSITION: absolute; TOP: 8px" runat="server">Label</asp:Label>
[bold]Step 2: main.aspx.vb [/bold] Dim myconnection As SqlConnection
Dim myda As SqlDataAdapter
Dim ds As DataSet
Dim mydr As DataRelation
Try
myconnection = New SqlConnection("server=localhost;database=northwind;uid=sa;password=;")
myda = New SqlDataAdapter("Select * from Orders", myconnection)
ds = New DataSet()
myda.Fill(ds, "Orders")
myda.SelectCommand.CommandText = "Select * from [Order Details]"
myda.Fill(ds, "OrdersDet")
mydr = New DataRelation("OrderRelation", ds.Tables(0).Columns("Orderid"), ds.Tables(1).Columns("Orderid"))
ds.Relations.Add(mydr)
Dim dr1 As DataRow
Dim dr2 As DataRow
Dim strval As String
For Each dr1 In ds.Tables(0).Rows
strval = strval & "<b>" & dr1("Orderid") & "</b> ---------------- "
For Each dr2 In dr1.GetChildRows(mydr)
strval = strval & "Productid: " & dr2("Productid") & " UnitPrice : " & dr2("UnitPrice") & "
"
Next
Next
Label1.Text = (strval)
Catch ex As Exception
Response.Write(ex.Message)
End Try
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More ASP.NET Code Articles More By aspfree developerWorks - FREE Tools! | This demonstration gives you an overview of IBM® Rational® Build Forge Express Edition, a global offering that provides a framework to automate and execute software processes. Rational Build Forge provides a software assembly line that can support all of your tools, technologies, and platforms so you can achieve a repeatable, reliable, and traceable build and release process. FREE! Go There Now!
| | | | Hear how IBM Rational Project and Portfolio Management integrated solutions help teams put the right tools and processes in place to maximize the effectiveness and efficiency of project teams and ensure that the business vision is being executed correctly. Learn how to automate and integrate requirements prioritization, top-down project planning, communications and controls, and methodology deployment to keep your scope, costs, and schedules under control. Tackle with an end-to-end approach the management of scope and scope changes, usage of methodology to control and empower project teams, and optimization of resources to align activity costs with the overall project plan. FREE! Go There Now!
| | | | You probably have thousands of lines of COBOL code loaded with business intelligence and being used to run your business, along with an army of developers maintaining these applications. Learn how to prepare your applications and developers so you can keep that competitive edge and move to a service-oriented architecture with the IBM Rational Enterprise Modernization solutions. Replay is available for 9 months. FREE! Go There Now!
| | | | CakePHP is a stable production-ready, rapid-development aid for building Web sites in PHP. This "Cook up Web sites fast with CakePHP" series shows you how to build an online product catalog using CakePHP. FREE! Go There Now!
| | | | Download a free trial version of IBM Rational Developer for System i V7.1, which provides a complete development environment for traditional i5/OS application development. IBM Rational Developer for System i is a new eclipse-based workstation offering for i5/OS application development that provides a comprehensive Integrated Development Environment for edit/compile/debug of traditional RPG/COBOL/C/C++ i5/OS applications. FREE! Go There Now!
| | | | Secure your Web applications with IBM Rational AppScan Standard Edition V7.7, previously known as Watchfire AppScan. This Web application security testing tool automates vulnerability assessments and scans and tests for common Web application vulnerabilities. Visit IBM developerWorks to download a free trial of IBM Rational AppScan Standard Edition V7.7. FREE! Go There Now!
| | | | Portfolio Management is about effectively managing portfolio value by aligning portfolio investments with business goals. This complimentary e-kit provides a collection of materials that can help you understand how IBM Rational enables and automates best practices for improved governance and clear visibility into portfolio and project performance across the entire IT project lifecycle. FREE! Go There Now!
| | | | Rational Modeling Extension for Microsoft .NET enhances usability for code generation supporting a more intelligent refactoring. The latest enhancements enable organizations with Java and .NET systems and software development maintain architectural integrity across heterogeneous platforms. FREE! Go There Now!
| | | | As businesses grow increasingly dependent upon Web applications, these complex entities grow more difficult to secure. Most companies equip their Web sites with firewalls, Secure Sockets Layer (SSL), and network and host security, but the majority of attacks are on applications themselves – and these technologies cannot prevent them. This paper explains what you can do to help protect your organization, and it discusses an approach for improving your organization’s Web application security. FREE! Go There Now!
| | | | The unprecedented scope of a service-oriented architecture (SOA) initiative brings to the forefront a number of management and governance issues that were sidestepped in the past. The key to a successful SOA implementation is managing and governing activities throughout the entire SOA delivery lifecycle by ensuring that services conform to the needs of all of the business’s stakeholders. Learn how service lifecycle management allows the business to ensure that the process by which services are defined, created, tested, deployed, optimized and retired is manageable, repeatable and auditable. FREE! Go There Now!
| | | | All FREE IBM® developerWorks Tools! | |