How to mask vbscript DB connection in ASP.net 2.0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ting ting
    New Member
    • Sep 2007
    • 15

    How to mask vbscript DB connection in ASP.net 2.0

    I am using ASP.net 2.0 and I wanna use some vbscript to get data. But I dun want to dispaly the DB connection string when the users right click the page and view the sources.

    I tried this method but not work. (It works in ASP.net 1.0)
    1. Add AspCompat="true " at the top of the page, use <!--#include virtual="common/DBconn.inc"--> to define a variable
    <%
    Const DB_CONNECT_STRI NG = "PROVIDER=MSDAS QL;XXXXXXXX%>

    <script language="vbs">
    set adocon=CreateOb ject("ADODB.Con nection")
    'Set the connectionstrin g
    adocon.Connecti onString =DB_CONNECT_STR ING


    </script>

    Any idea??
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    You're using ASP.NET.

    Do it in the "code behind" page.

    Comment

    • ting ting
      New Member
      • Sep 2007
      • 15

      #3
      Can you give me more details in code?

      Since I tried to put the connection string value in the hidden value, but it still can be browsed by the source code.

      Comment

      • DrBunchman
        Recognized Expert Contributor
        • Jan 2008
        • 979

        #4
        Hi ting ting,

        I'm a bit confused by this; why you are using VBScript to access your database?

        Database access is a server side function so should be written using ASP.NET which, as it runs on the server, can not be seen by viewing the source on the client.

        Are you sure you are structuring your code in the right way? Or have I missed something!?

        Dr B

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          Hmm yes, putting the connection objects in vbscript will make the client computer generate the connection to the database and not the server.

          Are you sure you are even doing ASP at all? Sounds like regular old html with vbscript.

          Comment

          • ting ting
            New Member
            • Sep 2007
            • 15

            #6
            Thanks for your reply. Since I wonder calling the function by vbscript is faster than generate at server and less refresh and post-back between servers.
            Any other suggestions on the masking or ideas to reduce the "refresh"??
            As I can mask the connection in ASP 1.0 but dunno why not in ASP 2.0??

            Originally posted by Plater
            Hmm yes, putting the connection objects in vbscript will make the client computer generate the connection to the database and not the server.

            Are you sure you are even doing ASP at all? Sounds like regular old html with vbscript.

            Comment

            • DrBunchman
              Recognized Expert Contributor
              • Jan 2008
              • 979

              #7
              The database connection MUST be opened on the server and therefore must be opened using server side code.....I don't understand how using client side vbscript is saving you time here!

              I store all my connection strings in my web.config file which can be accessed by my server side code and is in no danger of being seen by any users.

              Comment

              Working...