Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

FREE 12 month online training for ASP.NET & MS Expression Studio and a Free copy of MS Expression Web with Windows Server Purchase
Creating and hiding OverLoaded Delete Functions in VB.Net

Author: DevASP
Download Source Code : 418_Delete Code And DLL.zip

In this Article I will show that how we can hide our Delete OverLoaded Functions. which Actually can Holds Our Query Strings. Source Code is given with this Article

Query Strings our some times Shows Your Whole Logic (What You Are Trying to do with Database) in Asp.net. Is Asp.net project is running on internet then its Ok because now We have SSL (Security Socket Layer) But When We Run it on LAN (Local Area Networks) in Any Organization then it is possible That your Query Strings can Helps to Understand Your Logic.

 

For the better Understanding Follow These Steps.

 

1-Open new Project and Select Class Library from New Project Modules Showing on Right Side of window. 

2-Make your Connection string in that class.

3-Now make the connection function given below:

 

Public Function Connect(ByVal ConnectionStr)

        Cn.ConnectionString = ConnectionStr

        Try

            Cn.Open()

            myCm.Connection = Cn

            msgConnect = "Connection Established Successfully "

        Catch ex As Exception

            msgConnect = ex.Message & "Connection Error "

        End Try

        CheckFlag = "False"

    End Function

 

4-Then make Delete Function in which we Active the query string.

 

'delete is Used for owner

Public Function Delete(ByVal Table, ByVal WhereFeild, ByVal SetFeild)

 

myCm.CommandText = "Delete " & Table & " Where " & WhereFeild & "= '" & SetFeild & "'"

 

myCm.CommandType = CommandType.Text

 

 Try

        myCm.ExecuteNonQuery()

        msgDelete = "Record Deleted Succesfully"

 Catch ex As Exception

        msgDelete = ex.Message & "Deletion Error "

End Try

End Function

 

Now if You Run And Use it will fulfill your Simple Delete Requirements. But sometime we need to make where Clause more then one Field Then we have to create Overloaded Function Which is Just Differ by no of Fields.

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< How to create application with sliding messeges on Status bar using JavaScript in ASP.Net (Part 16)

Disclaimer - Privacy
© 2002-2014 DevASP.net