| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |
|

10-04-05, 15:58
|
|
Registered User
|
|
Join Date: Feb 2004
Location: Irving, TX (Dallas, Fort Worth)
Posts: 376
|
|
|
Noobie Trying but not understanding
|
|
All,
I'm new to VBScript.
I'm getting errors on my page and have no clue of how to troubleshoot/debug.
Was going to post code, but too much so attached as .txt file. There are three sections:
1. Actual Web Page (.html)
2. Module1 (Global definitions - contains most functions)
3. Class1 (Processing Class Module)
Since I'm so new at this I don't know how to:
1. Actually debug,
2. What the form actions and methods are,
3. What the script naming and calling conventions are,
4. How to link or make sure my Modules process,
5. How to correctly call my subroutines for processing.
I looked at several online help sources. The best seemed to be at:
http://www.w3schools.com/vbscript/default.asp
but nothing I look at really tells me how to. I would assume the most simplist thing is to talk about naming conventions, but find no help on that.
I quess the authors of those assume you know all this.
Can someone help me get past my hurdles so I can finish this code?
Thanks!
DBS4M
|
|

10-04-05, 20:50
|
|
Registered User
|
|
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
|
|
Wow, there's a whole pile of questions there and most of them with a massive scope...
I'll start with some of the easier ones...
Naming Conventions
There are as many answers to this as there are grains of sand on a beach. Basically the naming convention you use does matter a lot as long as it is
a. Consistant
b. Understandable (atleast by you, at best by everyone else)
c. Consistant
d. Flexible enough to deal with all your situations
e. Consistant
Personally I use camel case in most case so you get things like someVariable, anotherVariableName. Constants are always CAPITALS. References to objects are normally prefixed with a three letter code to identify them eg. a connection object would be called conMyAccessDatabase, a recordset recSomeRecords.
Really it's up to you though.
Debugging
This is a little harder then you would expect if you haven't done much asp before. Basically the best idea IMO is to use the response.write command to spew out reams of data as you are going through your page. eg
Code:
Dim conDatabase
response.write "Create Database Connection Object<br>"
Set conDatabase = Server.CreateObject("ADODB.Connection")
response.write "Opening Database Connection<br>"
conDatabase.Open(myConnectionString)
response.write "Database Opened Connection<br>"
Depending what errors your page is throwing you might want to add a response.buffer = false line at the start of your page. This should mean that any output eg. response.writes are imediately sent down to the browser rather then waiting until the page is complete. You can also use response.end to halt page execution at any time. This can be handy if you are getting HTTP 500 error with no actual message to tell you what the problem is. By adding a response.end to you page and slowly moving it down through your code you can see where the page execution is getting to before the HTTP 500 occurs.
How's that for a starter??
|
|

10-05-05, 10:50
|
|
Registered User
|
|
Join Date: Feb 2004
Location: Irving, TX (Dallas, Fort Worth)
Posts: 376
|
|
|
Different Meaning and Question
|
|
Quote:
|
Originally Posted by rokslide
Naming Conventions
There are as many answers to this as there are grains of sand on a beach. Basically the naming convention you use does matter a lot as long as it is
a. Consistant
b. Understandable (atleast by you, at best by everyone else)
c. Consistant
d. Flexible enough to deal with all your situations
e. Consistant
|
I guess the term naming conventions means different things to different people. What I have to know is how to call by name the routine needed for processing. This is what I mean by naming conventions. This is what all the tutorials, help files and so far forums are totally silent about.
Example:
<INPUT id=ADD style="WIDTH: 74px; HEIGHT: 40px" type=button size=17 value="Add New" width="200" tabindex="18" onclick=Main name="ADD">
What is the value that is suppose to be in/at the "onclick=" in the button def inorder to call the right subroutine in the script and how is that correctly named in the script to be viewed/called from the button? Is the naming convention <scriptname>.<subroutine> or is it something else?
Quote:
Debugging
This is a little harder then you would expect if you haven't done much asp before. Basically the best idea IMO is to use the response.write command to spew out reams of data as you are going through your page. eg
Code:
Dim conDatabase
response.write "Create Database Connection Object<br>"
Set conDatabase = Server.CreateObject("ADODB.Connection")
response.write "Opening Database Connection<br>"
conDatabase.Open(myConnectionString)
response.write "Database Opened Connection<br>"
|
This I don't understand at all. What good is writing when the error is not trapped? This method only writes the exact text you insert into the .write statement, and has nothing to do with error trapping.
Debugging, again, must mean something different to you than to me. To me it is stepping through the code line by line and actually observing processing and/or errors. This is what I have not been able to do and so I cannot understand how find or fix problems in my code until I get to that level.
If you know how this is done let me know!
DBS4M
|
|

10-05-05, 11:51
|
|
Registered User
|
|
Join Date: Feb 2004
Location: Irving, TX (Dallas, Fort Worth)
Posts: 376
|
|
|
Progress
I now know that going into "Preview" in FP pulls up the debugger, but don't understand my errors. Debugger stops at:
Error is Type mismatch: Load_Form
in the following opening statements:
Code:
<!--#include file = "Globals.asp"-->
<!--#include file = "ClassProc.asp"-->
<script type="text/vbscript" language="vbscript" debug="true" id="Main">
<!--
dim ClsObj, GlbObj
call Load_Form(Me)
Select case ID
Case scADD
Add_New(Me)
Case scSAV
Save_Data(Me)
Case scDEL
Delete_Row(Me)
Case scSRC
Search_Agt(Me)
end Select
Load_Form is in the ClassProc.asp file, which does not seem to load.
DBS4M
|
Last edited by dbsupport4me; 10-05-05 at 11:57.
|

10-05-05, 12:37
|
|
Registered User
|
|
Join Date: Feb 2004
Location: Irving, TX (Dallas, Fort Worth)
Posts: 376
|
|
|
Why??
I went back into my included modules and made sure they were defined as Public, so why don't the Call statement work?
All the MSDN and other help files say it will! Are there error in the include file that are not showing keeping this from working?
DBS4M
|
|

10-05-05, 15:12
|
|
Registered User
|
|
Join Date: Feb 2004
Location: Irving, TX (Dallas, Fort Worth)
Posts: 376
|
|
|
Some Progress - Help Please
Got tired of banging on errors, since the includes were not working, so loaded the code local as follows:
Code:
<html>
<head>
<%@ import Namespace="System.Drawing" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<!--#include file = "Globals.asp"-->
<!--#include file = "ClassProc.asp"-->
<script type="text/vbscript" language="vbscript" debug="true" id="Main">
<!--
dim ClsObj, GlbObj
call Load_Form(Me)
Select case ID
Case "ADD"
Add_New(Me)
Case "SAV"
Save_Data(Me)
Case "DEL"
Delete_Row(Me)
Case "SRC"
Search_Agt(Me)
end Select
' sub scADD()
' Dim SCRf As Object
' Set SCRf = New Object
' SCRf.name = "Class1"
' SCRf.Add_New(Me)
' End Sub
Sub Load_Form(MyFrm)
Dim connStr, DtS1, DtS2, DtS3, DtS4, DtS5, QString, objCmd, objcon
connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\sdad2fs2\Utilities\ADS_Walnut_Scorecard\HD Tracking.mdb"
' objcon = Server.CreateObject("ADODB.Connection")
' objcon.Open connStr
objcon = OleDbConnection(connStr)
Call Clr_Flds
' Load the Agent Combo Box
QString = "SELECT empid, empName FROM tblEmployeeMaster ORDER BY empName;"
objCmd = OleDbDataAdapter(QString , objcon)
objCmd.Fill DtS1, "tblEmployeeMaster"
MyFrm.AGT.Rowsource = DtS1
MyFrm.AGT.Requery
' Load the Line of Business Combo Box
QString = "1, CPL/WTU, 2, GNG, 3, ORG"
MyFrm.LOB.Rowsource = QString
MyFrm.LOB.Requery
' Load the Escalation Combo Box
QString = "1, Yes, 2, No"
MyFrm.ESC.Rowsource = QString
MyFrm.ESC.Requery
' Load the Escalation Type Combo Box
QString = "1, Help Desk, 2, Internal, 3, CSO"
MyFrm.ETP.Rowsource = QString
MyFrm.ETP.Requery
' Load the Escalation To Combo Box
QString = "SELECT * FROM qryTCShDesk;"
objCmd = OleDbDataAdapter(QString , objcon)
objCmd.Fill DtS2, "qryTCShDesk"
MyFrm.AGT.Rowsource = DtS2
MyFrm.AGT.Requery
' Load the Resolver Combo Box
QString = "SELECT * FROM qryTCShDesk;"
objCmd = OleDbDataAdapter(QString , objcon)
objCmd.Fill DtS3, "qryTCShDesk"
MyFrm.AGT.Rowsource = DtS3
MyFrm.AGT.Requery
' Load the Res Type Combo Box
QString = "SELECT * FROM tblHDtype;"
objCmd = OleDbDataAdapter(QString , objcon)
objCmd.Fill DtS4, "tblHDtype"
MyFrm.AGT.Rowsource = DtS4
MyFrm.AGT.Requery
' Load the Reason Combo Box
QString = "SELECT * FROM tblHDreason ORDER BY rsnDESC ASC;"
objCmd = OleDbDataAdapter(QString , objcon)
objCmd.Fill DtS5, "tblHDreason "
MyFrm.AGT.Rowsource = DtS5
MyFrm.AGT.Requery
' Load the Status Combo Box
QString = "1, Escalated, 2, Pending, 3, Resolved"
MyFrm.STS.recordsource = QString
MyFrm.STS.Requery
End Sub
Sub Clr_Flds(MyFrm)
MyFrm.[AGT] = Null
MyFrm.[AID] = Null
MyFrm.[ANI] = Null
MyFrm.[CDT] = Null
MyFrm.[COC] = Null
MyFrm.[DCC] = Null
MyFrm.[DET] = Null
MyFrm.[ESC] = Null
MyFrm.[EST] = Null
MyFrm.[ETP] = Null
MyFrm.[LID] = Null
MyFrm.[LOB] = Null
MyFrm.[RCD] = Null
MyFrm.[RES] = Null
MyFrm.[RID] = Null
MyFrm.[RTP] = Null
MyFrm.[SUP] = Null
MyFrm.[STS] = Null
Add_Flag = False
End Sub
-->
</script>
<title>ADS Help Desk Tracking</title>
<meta http-equiv="Content-Language" content="en-us">
<script type=text/javascript language="javascript">
<!--
//-->
</script>
</HEAD>
<BODY>
<P> </P>
<CENTER><FONT face=Verdana size="+5"><B>Help Desk Tracking Database</B></FONT>
</CENTER>
<P> </P>
<form method=post name=MainForm action=classproc.asp id=MainForm>
<INPUT id=RID style="Z-INDEX: 7; WIDTH: 1.5in" tabIndex=7 type=hidden>
<TABLE width="95%" align=center border=0>
<TR>
<TD>
<TABLE width="99%" border=5>
<TR>
<TD><FONT face=Verdana size=+2 ,><B>Originator:</B></FONT></TD>
</TR>
<TR>
<TD>
<TABLE width="95%" border=0>
<TR>
<TD align=right>Agent:</TD>
<TD><SELECT id=AGT style="Z-INDEX: 1; WIDTH: 1.5in" tabIndex=1 onchange=Main.scACH><OPTION selected></OPTION></SELECT><font color="#FF0000">*</font></TD>
<TD align=right>Call Date:</TD>
<TD><INPUT id=CDT style="Z-INDEX: 4; WIDTH: 1.5in" tabIndex=4></TD>
<TD align=right>Account ID:</TD>
<TD><INPUT id=AID style="Z-INDEX: 7; WIDTH: 1.5in" tabIndex=7><font color="#FF0000">*</font></TD>
<TD align=right>Escalation:</TD>
<TD><SELECT id=ESC style="Z-INDEX: 10; WIDTH: 1.5in" tabIndex=10><OPTION selected></OPTION></SELECT><font color="#FF0000">*</font></TD>
</TR>
<TR>
<TD align=right>Super:</TD>
<TD><INPUT id=SUP style="Z-INDEX: 2; WIDTH: 1.5in" tabIndex=2></TD>
<TD align=right>Login ID:</TD>
<TD><INPUT id=LID style="Z-INDEX: 5; WIDTH: 1.5in" tabIndex=5></TD>
<TD align=right>Coached:</TD>
<TD><SELECT id=COC style="Z-INDEX: 8; WIDTH: 1.5in" tabIndex=8><OPTION selected></OPTION></SELECT><font color="#FF0000">*</font></TD>
<TD align=right>Esc. Type:</TD>
<TD><SELECT id=ETP style="Z-INDEX: 11; WIDTH: 1.5in" tabIndex=11><OPTION selected></OPTION></SELECT><font color="#00aa00">**</font></TD>
</TR>
<TR>
<TD align=right>LOB:</TD>
<TD><SELECT id=LOB style="Z-INDEX: 3; WIDTH: 1.5in" tabIndex=3><OPTION selected></OPTION></SELECT><font color="#FF0000">*</font></TD>
<TD align=right>ANI/Phone:</TD>
<TD><INPUT id=ANI style="Z-INDEX: 6; WIDTH: 1.5in" tabIndex=6><font color="#FF0000">*</font></TD>
<TD align=right>Date Coached:</TD>
<TD><INPUT id=DCC style="Z-INDEX: 9; WIDTH: 1.5in" tabIndex=9></TD>
<TD align=right>Escalated to:</TD>
<TD><SELECT id=EST style="Z-INDEX: 12; WIDTH: 1.5in" tabIndex=12><OPTION selected></OPTION></SELECT><font color="#00aa00">**</font></TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD> </TD></TR>
<TR>
<TD>
<TABLE width="99%" border=5>
<TR>
<TD><FONT face=Verdana size=+2 ,><B>Resolver:</B></FONT></TD></TR>
<TR>
<TD>
<TABLE width="93%" border=0>
<TR>
<TD align=right>Resolver:</TD>
<TD><SELECT id=RES style="Z-INDEX: 13; WIDTH: 1.5in" tabIndex=13><OPTION selected></OPTION></SELECT></TD>
<TD align=right>Res Type:</TD>
<TD><SELECT id=RTP style="Z-INDEX: 14; WIDTH: 1.5in" tabIndex=14><OPTION selected></OPTION></SELECT></TD>
<TD align=right>Reason Code:</TD>
<TD><SELECT id=RCD style="Z-INDEX: 15; WIDTH: 2in" tabIndex=15><OPTION selected></OPTION></SELECT></TD>
<TD align=right>Status:</TD>
<TD><SELECT id=STS style="Z-INDEX: 16; WIDTH: 1in" tabIndex=16><OPTION selected></OPTION></SELECT></TD></TR>
<TR>
<TD vAlign=top align=right>Details:</TD>
<TD colSpan=7><TEXTAREA class=MsoTextbox id=DET style="Z-INDEX: 17; WIDTH: 1020; HEIGHT: 100" tabIndex=17 rows=1 cols=60></TEXTAREA></TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD> </TD>
</TR>
<TR>
<TD>
<TABLE align=center border=0 width=60%>
<TR>
<TD align=middle><INPUT id=ADD style="WIDTH: 74px; HEIGHT: 40px" type=button size=17 value="Add New" width="200" tabindex="18" onclick=Main name="ADD"></TD>
<TD align=middle><INPUT id=CLR style="WIDTH: 74px; HEIGHT: 40px" type=reset size=17 value=Clear width="200" tabindex="19"></TD>
<TD align=middle><INPUT id=SAV style="WIDTH: 74px; HEIGHT: 40px" type=button size=17 value=Save width="200" tabindex="20" onclick=Main.scSAV name="SAV"></TD>
<TD align=middle><INPUT id=DEL style="WIDTH: 74px; HEIGHT: 40px" type=button size=17 value=Delete width="200" tabindex="21"
onclick="return confirm('Are you sure you want to delete this record?')" name="DEL"></TD>
<TD align=middle><INPUT id=SRC style="WIDTH: 74px; HEIGHT: 40px" type=button size=17 value=Search width="200" tabindex="22" onclick=Main.scSRC name="SRC"></TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD> </TD>
</TR>
<TR>
<TD align=center><font color="#FF0000">* Denotes Required Fields</font>  <font color="#00aa00">** Required if Previous Field
Selected Value = <b>"Yes"</b></font></TD>
</TR>
</TABLE>
</form>
</BODY>
</HTML>
Now the debugger always stops at line 33 on OleDbConnection and says:
Quote:
|
Type MisMatch: OleDbConnection
|
I assume the import that I got from an online source, setup with:
Code:
<%@ import Namespace="System.Drawing" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
is not loading the OleDb objects, but do not have any idea why.
Help Please!
DBS4M
|
|

10-05-05, 18:48
|
|
Registered User
|
|
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
|
|
Look sto me like you are trying to mix asp.Net and classic asp. Pick one and you should find your life a bit easier.
Trapping errors in classic asp (which I assumed you were writing in) is notoriously difficult as is getting the debbugers to work. So we tend to response.write messages out to locate the error and then deal with it. Error messages in classic asp can be very misleading.
Calling functions or stored procedures has nothing to do with naming conventions. It is simply "call subroutine_name()" or "n=function_name()".
|
|

10-05-05, 19:25
|
|
Registered User
|
|
Join Date: Feb 2004
Location: Irving, TX (Dallas, Fort Worth)
Posts: 376
|
|
|
Hum???? What didn't I say????
Quote:
|
Originally Posted by rokslide
Look sto me like you are trying to mix asp.Net and classic asp. Pick one and you should find your life a bit easier.
Trapping errors in classic asp (which I assumed you were writing in) is notoriously difficult as is getting the debbugers to work. So we tend to response.write messages out to locate the error and then deal with it. Error messages in classic asp can be very misleading.
Calling functions or stored procedures has nothing to do with naming conventions. It is simply "call subroutine_name()" or "n=function_name()".
|
Sorry All, but I believe I said I know absolutely nothing about VBScript, never used it before so dumb as mud. I don't know ASP from @#$%!!!!
So how am I to know if I'm writing in one or the other?????????????????
All I said I know is VB and VBA which is what I'm trying to use, and adopt and/or tweak to VBScript as I' dumb as mud....
Now I've put onclick="Call Main" and set id="Main" in my main script. So again I'm dumb as mud so why doen't anything work?????
Right now I consider that I've made progress as my main script actually runs, to a point. The place I'm having trouble is:
Code:
QString = "SELECT empid, empName FROM tblEmployeeMaster ORDER BY empName;"
' connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\sdad2fs2\Utilities\ADS_Walnut_Scorecard\MScorecard.mdb"
set dbs = connStr.OpenCurrentDatabase("\\myServer\MyDB.mdb")
objcon = dbs.OpenConnection("MScorecard.mdb")
objcon.Open QString
' objcon = dbs.CreateObject("ADODB.Connection")
' objcon.Open connStr
' Set rss1 = dbs.openrecordset(QString)
' objcon = OleDbConnection(connStr)
I can not get the DB connection to open at all. I used to get an error saying it was a permissions issue with the remote site, but I've re-written and tweaked this code probably 100 times since then and have literally driven myself crazy; looking up online help, trying a new approaches, getting the same or similar errors and pulling out all my hair (what I have left HA!!).
Anyway I'm not complaining about the help, just saying I'm so dumb I have no reference as to what you guys are saying so you have to be very specific, so I can grasp it.
Thanks all!
DBS4M
|
|

10-05-05, 21:58
|
|
Registered User
|
|
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
|
|
Well classic asp uses vbscript and does not use your import statements that you have at the top there.
Asp.Net uses C# or VB.Net and can use the import statements.
If you are coming from a vb/vba back ground I would be tempted to say go with classic asp as it is a little easier to understand, especially when trying to wrap your head around client server interactions.
If I had some time I would attempt to try and re-write your page for you, but unfortunately I'm pretty flat out atm.
|
|

10-06-05, 10:36
|
|
Registered User
|
|
Join Date: Feb 2004
Location: Irving, TX (Dallas, Fort Worth)
Posts: 376
|
|
Rok,
Thanks! I at least understand a little more.
DBS4M
|
|

10-06-05, 11:11
|
|
Registered User
|
|
Join Date: Oct 2005
Posts: 5
|
|
Rok is right. Classic ASP would be easier to get going with and WC3Schools website is perfect for learning. I've had it bookmarked for 3 years. Focus on the ASP section not the ASP.Net section.
It may help if you explain your topology. Are you doing this programming on a webserver? Is the database you're attempting to hit on the same server or another server? Is it SQL or Oracle or something else like Access?
|
|

10-06-05, 11:53
|
|
Registered User
|
|
Join Date: Feb 2004
Location: Irving, TX (Dallas, Fort Worth)
Posts: 376
|
|
MadDog,
DB is on a network sever. DB is Access. Will convert to MySQL or MS-SQL later.
Have been looking at WC3Schools but still too dumb to understand much, but finally starting to comprehend a little. I do have FP installed and run the debugger on the script and it keep blowing at the DB connection.
Have tried several connection solutions, but don't know what, how, who is right. That is where I've been for the last 16 hours, going nuts.
HHHHHHHHHHHHHHEEEEEEEEEEEELLLLLLLLLLLLLLLLLLPPPPPP PPPPPPPPP!!!!!!!!!!!!!!!
DBS4M
|
|

10-06-05, 12:29
|
|
Registered User
|
|
Join Date: Oct 2005
Posts: 5
|
|
DBS4M,
OK. Let's start slowly. Here is a snippet of code that connects to my Access database. Keep in mind that I'm running this all on my local machine.
This example connects to the database, queries the tn_test table in the database, then loops through all the records and displays the value of the cn_description column to the browser.
<%
'Instantiate a new ADO connection.
Set conDb = Server.CreateObject("ADODB.Connection")
'Open connection.
conDb.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Temp\AccessTest.mdb" & ";"
'Instantiate a new recordset.
Set rsRecords = Server.CreateObject("ADODB.recordset")
'Define query string.
qsRecords = "Select * From tn_Test"
'Open the recordset.
rsRecords.Open qsRecords, conDb
'Loop through the records and write to browser.
Do While Not rsRecords.EOF
'Write the value from column cn_description.
Response.Write rsRecords("cn_description") & "<br>"
'Move to the next record.
rsRecords.MoveNext
Loop
'Close the database connection.
conDb.Close
%>
So, start simple and build out from there. Also, you may want to look through the ADO section on W3Schools site.
Good luck,
Maddog
|
|

10-06-05, 14:19
|
|
Registered User
|
|
Join Date: Oct 2005
Posts: 5
|
|
DBS4M,
Also, when the time comes, you can take advantage of the GLOBAL.ASA file. In our production environment I create a number of session variables that establish the database and connections strings. I can then just refer to them in my code when I'm ready to create the connection. Therefore, I have 1 location for for my database and connection information instead of every page that requires a connection!
Thanks,
Maddog
|
|

10-10-05, 10:27
|
|
Registered User
|
|
Join Date: Feb 2004
Location: Irving, TX (Dallas, Fort Worth)
Posts: 376
|
|
|
Had to check myself
Wrote so much and been on so many forums, trying to solve this problem, had to check myself on this thread to see what I said.
MadDog,
My problem with your code is the term "Server" in my system on the .ASP/.HTML side, comes up as an unknown and I have not been able to get past this.
If you know what is causing this error kudos!!!!!!!!!
DBS4M
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|