ASP.NET
  Home arrow ASP.NET arrow Page 2 - Developing a Data Access Layer for Sybase ...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Developing a Data Access Layer for Sybase using ADO.NET: Essentials Continued
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2006-03-27

    Table of Contents:
  • Developing a Data Access Layer for Sybase using ADO.NET: Essentials Continued
  • Binding a dropdown list with information from Sybase database using ADO.NET: explanation
  • Getting a dataset of information from Sybase database using ADO.NET
  • Getting a row of information from Sybase database using ADO.NET

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Developing a Data Access Layer for Sybase using ADO.NET: Essentials Continued - Binding a dropdown list with information from Sybase database using ADO.NET: explanation


    (Page 2 of 4 )

    This section mainly deals with the explanation of the code listed in the previous section.  Let me explain it part by part:

                Dim dt As DataTable = getDataTable(sqlSELECT)
                If dt.Columns.Count < 2 Then
                    Throw New Exception("Atleast 2 cols are required
    to bind, Given SQL Statement: " & sqlSELECT)
                End If

    The above part mainly retrieves the information based on the SELECT statement passed to it.  It also checks whether the information is retrieved in the form of two columns or not.  If not, it would raise an error.

                If ClearExistingItems Then dl.Items.Clear()
                If Not Caption Is Nothing Then
                    dl.Items.Add(New ListItem(Caption, Caption))
                    dl.Items.Add(New ListItem("-".PadLeft(150, "-"),
    Caption))
                End If

    The above part first tries to clear the dropdown list based on the parameter we pass.  If we provide some “caption” to display, then it would be added as the first element along with a separator.  Further proceeding, we have the following:

                Dim dr As DataRow
                If ShowIDandDESCSeparated Then
                    For Each dr In dt.Rows
                        dl.Items.Add(New ListItem(dr(0) & " - " & dr
    (1) & "", dr(0) & ""))
                    Next
                Else
                    For Each dr In dt.Rows
                        dl.Items.Add(New ListItem(dr(1) & "", dr(0) &
    ""))
                    Next
                End If
                dl.SelectedIndex = -1

    The above part gets divided into two parts.  One is related to adding items with both key and description and the other is related to adding items with only description, without the key.  One of the parts gets executed based on the parameter we specify for “ShowIDandDESCSeparated.”  The last statement is mainly used to make the dropdown list point to no item after binding.

    More ASP.NET Articles
    More By Jagadish Chaterjee


       · Hello guys. This is another contribution for the same series on developing a DAL...
     

    ASP.NET ARTICLES

    - Developing a Mini ASP.NET AJAX Server Centri...
    - Disadvantages of the ASP.NET MVC Framework
    - Advantages of the ASP.NET MVC Approach
    - ASP.NET Web Forms Weaknesses
    - ASP.NET Web Forms Meets ASP.NET MVC
    - Source Code for Saving and Retrieving Data w...
    - Using GridView to Save and Retrieve Data wit...
    - Handling Dynamic Images in ASP.NET 3.5 AJAX ...
    - Retrieving Data with AJAX and the GridView C...
    - Playing with Images in ASP.NET 3.5 AJAX Appl...
    - Saving and Retrieving Data with AJAX
    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX

     
    Best Practices for Windows Vista Migration Presentation
    Dell and Microsoft recently held a series of face-to-face seminars entitled, &qu....

     
    Creating a Culture for Code Reuse
    If you oversee development teams you know that like it or not proprietary and ex....

     
    Keys to Web Application Acceleration: Advances in Delivery Systems
    Accelerate Web apps by up to 5x. Ensure significantly faster access to the Web a....

     
    Optimizing Application Monitoring
    Tired of finding out from your customers that you're offline? This white paper e....

     
    Solaris to Solaris Migration -- Migrating applications from Sun SPARC to Dell PowerEdge R900
    This comprehensive Migration Guide reviews the approach that Principled Technolo....

     




    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT