Thread: VBScript Code

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    58
    Rep Power
    11

    VBScript Code


    Hii Theree

    I have been trying for so long but this simple code does not seems to work. I would really be grateful if you can plss help me out with this code.The button in the code is not working. It does not get activated on clicking and there isno error message that that I am getting. I am at my wit's end.plss help me.

    <html>

    <head> </head>

    <body>

    <form method="POST" action="--WEBBOT-SELF--">


    <input type="button" value="load data" OnClick="loaData();">


    </form>


    <script language="VBScript">


    sub loadData()

    dim conn
    dim rs
    dim qry

    msgbox "hi"

    Set conn = CreateObject("ADODB.Connection")
    conn.CursorLocation = 3
    Set rs = CreateObject("ADODB.Recordset")

    conn.Open "TestDB"

    ': Queries
    qry = "Select * from q4

    rs.Open qry, conn, adOpenStatic

    if not rs.eof then
    rs.movelast
    total = rs.recordcount
    rs.movefirst
    msgbox total & " records from Queries were loaded",,""
    end if

    conn.close
    set rs = nothing
    set conn = nothing

    end sub

    </script>

    </body>

    </html>

    Thanks so much

    Ravi
  2. #2
  3. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    792
    Your mixing different technologies here.
    A simple VBScript example:
    Code:
    <html>
    <script language="VBScript">
    	sub loadData_onClick
    		msgbox "Hi"
    	end sub
    </script>
    <body>
    <form method="POST" action="--WEBBOT-SELF--">
    <input type="button" name="loadData" value="load data">
    </form>
    </body>
    </html>
    Notice that the button name is set to "loadData" and the sub in the script section is called "loadData_onClick"

    The first section is the name, the second is the event. This sub will be executed on the click of the button.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    South Africa
    Posts
    3
    Rep Power
    0

    Unhappy VBScript Code


    I have noticed that you have not confined your coding to the standards as suggested in any programming manual when it comes to coding.

    The first problem you have is the key to why you can't debug your entire code set, first off your button should not contain any sub-routine that is terminated by the ";" token.

    Wrong:
    <input type="button" value="load data" OnClick="loaData();">

    Correnct:
    <input type="button" value="load data" OnClick="loaData()" language="VBS">

    Note: Try and declare your subroutines this way, emphasis on indentation and where the rroutine is defined.

    Public Sub LoadData()
    ....
    ....
    End Sub

    Fixing this will then allow you to get a plethora of Logical Errors and Syntax Error. These will then lead you ro what you are trying to get done.

    The second major problem you have shown is that you have not learnt how to properly manipulate database using VBScript. This topic is very wide, but I suggest you get with www.devguru.org, and get yourslef their latest VBScript Reference. This will guide you to how to solve your problem.

    I hope you have learnt a thing or two about VBScript, the most obvious is that it SUCKS!!!

IMN logo majestic logo threadwatch logo seochat tools logo