ASP.NET
  Home arrow ASP.NET arrow Page 7 - The Simplest CRUD Operations for Lookup Ta...
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

The Simplest CRUD Operations for Lookup Tables in ASP.NET
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 25
    2006-06-28

    Table of Contents:
  • The Simplest CRUD Operations for Lookup Tables in ASP.NET
  • The SQLHelper
  • The SQLHelper: continued
  • Retrieving information from the database
  • Dealing with DML operations
  • Dealing with DML Operations: continued
  • Points to note

  • 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


    The Simplest CRUD Operations for Lookup Tables in ASP.NET - Points to note


    (Page 7 of 7 )

    Even though I didn't talk about "delete" in the above sections, it is worth mentioning.  Actually, deleting a record is as simple as including the following:

      PrivateSub Delete(ByVal DeptID As String)
            db.SQLExecute("delete from dept where deptno=" & DeptID)
            BindGrid()
        End Sub

    I included the following JavaScript to add confirmation for the delete operation.

      <script  language="javascript">
                function getConfirm() 
                { 
                      if (confirm("Are you sure to delete record?")
    ==true
                            return true
                      else
                            return false
                }
                </script>

    To activate the above script, I included the following:

      PrivateSub DataGrid1_ItemDataBound(ByVal sender As Object,
    ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
    Handles DataGrid1.ItemDataBound
            Select Case e.Item.ItemType
                Case ListItemType.Item, ListItemType.AlternatingItem
                    e.Item.Cells(1).Attributes.Add("onclick", "return
    getConfirm();")
            End Select
        End Sub

    To work with my sample, I simply created a table "dept" using the following command:

      CREATE TABLE [dbo].[dept] (
          [deptno] [int] NOT NULL ,
          [dname] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
    NULL ,
          [loc] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
    NULL
     
    ) ON [PRIMARY]

    Try to insert some rows into the above table using following commands:

      insert into dept values (10,'Accounting','Dallas')

      insert into dept values (20,'Production','Washington')

    The entire code for this article is freely available in the form of a zip file.  That downloadable solution was developed using Microsoft Visual Studio 2003 Enterprise Architect together with SQL Server 2000 on Microsoft Windows 2003 Standard Edition. I didn't really test it in any other version. 

    Any doubts, bugs, errors, suggestions, feedback etc. are highly appreciated at jag_chat@yahoo.com.


    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.

       · why wouldn't you use a tableadapter?or the MS Enterprise Library?
       · ofcourse, I would have used. But, I didn't mean to use enterprise library in this...
     

    ASP.NET ARTICLES

    - 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
    - Building a Simple Storefront with LINQ

     
    Application Delivery: Everything You Wanted to Know, but Didn`t Know You Needed to Ask
    A comprehensive guide to examining the topics of Wide-area Data Services and app....

     
    Best Practices: Safe and Secure Hardware Asset Recovery
    Companies increasingly must meet EPA and local requirements for the disposal of ....

     
    Managing SSL Security in Multi-Server Environments
    Read this white paper to learn how to simplify management of your organization's....

     
    Open Source Security Myths
    Open Source Software (OSS) is computer software whose source code is available t....

     
    Power and Cooling Capacity Management for Data Centers
    This paper describes the principles for achieving power and cooling capacity man....

     




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