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
 

How to Hide Insert And Update Query Strings

Author: DevASP
Download Source Code : 411_Insert And Update Code And DLL.zip

In this Article I will show that how we can Hide our Select Query.

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 to others.

 

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 Insert Function in which we make the Insert query string.

 

Public Function Insert(ByVal Table, ByVal Feild1, ByVal Feild2, ByVal Feild3)

        myCm.CommandText = "insert into " & Table & "  values ( '" & Feild1 & "' , '" & Feild2 & "','" & Feild3 & "')"

        myCm.CommandType = CommandType.Text

        Try

            myCm.ExecuteNonQuery()

            msgInsert = "Record Inserted Successfully "

        Catch ex As Exception

            msgInsert = ex.Message & "Record Insert Error "

        End Try

    End Function

 

5-Then make Insert Function in which we make the Insert query string

 

Public Function Update(ByVal TableName, ByVal Feild1, ByVal Feild2, ByVal Feild3, ByVal Feild4, ByVal Feild5, ByVal Feild6, ByVal Feild7, ByVal Feild8, ByVal Feild9, ByVal Feild10, ByVal Feild11, ByVal Feild12, ByVal Feild13, ByVal Feild14, ByVal Feild15)

 

myCm.CommandText = "Update " & TableName & " set " & "name" & " = '" & Feild2 & "', " & "street1" & " = '" & Feild3 & "', " & "street2" & " = '" & Feild4 & "', " & "street3" & " = '" & Feild5 & "', " & "postal1" & " = '" & Feild6 & "', " & "postal2" & " = '" & Feild7 & "', " & "postal3" & " = '" & Feild8 & "', " & "home" & " = '" & Feild9 & "', " & "work" & " = '" & Feild10 & "', " & "Mobile" & " = '" & Feild11 & "', " & "fax" & " = '" & Feild12 & "', " & "Email" & " = '" & Feild13 & "', " & "Account_Name" & " = '" & Feild14 & "', " & "Account_Number" & " = '" & Feild15 & "' where " & "OwnerCode" & " = '" & Feild1 & "'"

 

myCm.CommandType = CommandType.Text

 

        Try

            myCm.ExecuteNonQuery()

            msgUpdate = "Record Updated Successfully "

        Catch ex As Exception

            msgUpdate = ex.Message & "Record Update Error "

        End Try

 

End Function

 

6- Build the project.

7- Now close the code window and go to the location where your project is stored in bin folder you find the dll.

8- New Project Web Application in Asp.net using Vb language.

9-Now On right side you will find the solution explorer where You find the Resources. By  right click on resources you will find the add resources. 

10-add Your Dll Here.

 

Now use That Class As Built-in Asp.net Namespaces.

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Creating an XP Style File Menu (Part 1)

Disclaimer - Privacy
© 2002-2017 DevASP.net