Help on ASP procedure with VBScript

This is a discussion on "Help on ASP procedure with VBScript" within the Classic ASP section. This forum, and the thread "Help on ASP procedure with VBScript are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Apr 22nd, 2004, 16:06
New Member
Join Date: Apr 2004
Location: Canada
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Help on ASP procedure with VBScript

I am new to ASP and been bugged down with this problem.

<font color="red">Below is a portion of my code and it runs perfectly:
Now when I change the value of formCategory it will call the function CheckRequiredText() and that is where I encounter problem</font id="red">

<%
varStaffName=Request.Cookies("varStaffName")
varDescription=Request.Cookies("varModuleDescripti on")
formDateFrom=Request.Cookies("varFormDatefrom")
formDateTo=Request.Cookies("varFormDateTo")
strSQL= " SELECT ModuleCode, ProgressComponentCode, ProgressComponentDesciption, ProgressComponentWeight"
strSQL= strSQL + " FROM dbo.ProgressReportComponent WHERE ModuleCode = " & varModulelD
strSQL= strSQL + " ORDER BY ProgressComponentDesciption "
'response.write(strSQL)
Set Re2 = conn.Execute(strSQL)
%>

<select name="formCategory" size="1" style="width:200;COLOR:#669966;" onChange="CheckRequiredText() ">
<%
strSQL3= " SELECT ProgressReportCommentsTypeCode, ProgressReportCommentsTypeDescription"
strSQL3= strSQL3 + " FROM dbo.ProgressReportCommentType WHERE ModuleCode = " & varModulelD
Set Re3 = conn.Execute(strSQL3)
do until Re3.EOF
response.write "<option value= " & Re3("ProgressReportCommentsTypeCode") & "> " & Re3("ProgressReportCommentsTypeDescription") & "</option>"
Re3.MoveNext
loop
Re3.close
Set Re3 = Nothing
%>
</select>


<font color="red">This is my CheckRequiredText() function. Everything is working on my function except when it connects to the database. That is when I get the error message "Error 424 Object Required" I can't figure out why my connection string is not working.</font id="red">

<SCRIPT LANGUAGE = "VBScript">
<!--
Private Function CheckRequiredText()

MsgBox "The " & Form.formCategory.options(Form.formCategory.select edIndex).value & " was the selected code."
varTypeCode= Form.formCategory.options(Form.formCategory.select edIndex).value
strSQL4=" SELECT ProgressReportCommentCode, ProgressReportCommentTypeCode, ProgressReportCommentDescription"
StrSQL4=strSQL4 + " FROM dbo.ProgressReportComment WHERE ProgressReportCommentTypeCode = " & varTypeCode
On Error Resume Next
MsgBox StrSQL4
Set Re4 = conn.Execute(strSQL4)

MsgBox "Error # " & CStr(Err.Number) & " " & Err.Description

End Function

----------------------------
<font color="red">This is the value of my conn</font id="red">
Set conn = Server.CreateObjectADODB.Connection)
conn.ConnectionTimeout = 30
conn.CommandTimeout = 30
conn.Open (Provider=SQLOLEDB;UID=ourUserID;Password=ourPassw ord;Initial Catalog=ourCatalog;Data Source=ourdatabasename and location)


Can someone help me figure out the solution to my problem.

  #2 (permalink)  
Old Apr 22nd, 2004, 17:56
Reputable Member
Join Date: Aug 2003
Location: United Kingdom
Posts: 341
Thanks: 0
Thanked 0 Times in 0 Posts
is varTypeCode an integer or string?
  #3 (permalink)  
Old Apr 22nd, 2004, 19:02
New Member
Join Date: Apr 2004
Location: Canada
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Hi
Thanks for replying
I varTypeCode is an integer as it was derived from the index value of a SELECT field.

Terry

<blockquote id="quote"><font size="1" face="geneva, verdana, arial" id="quote">quote:<hr height="1" noshade id="quote">Originally posted by D3mon

is varTypeCode an integer or string?
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">
  #4 (permalink)  
Old Apr 22nd, 2004, 20:00
Reputable Member
Join Date: Aug 2003
Location: United Kingdom
Posts: 341
Thanks: 0
Thanked 0 Times in 0 Posts
<s>OK, did you define Re4 as a recordset?</s>
There's your problem, you appear to be trying to access your database from client-side script. While this may be possible it would mean revealing your DB connection details in the client-side code - a potentially fatal mistake.
  #5 (permalink)  
Old Apr 22nd, 2004, 21:44
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
this code:-
Code: Select all
Set conn = Server.CreateObjectADODB.Connection)
conn.ConnectionTimeout = 30
conn.CommandTimeout = 30
conn.Open (Provider=SQLOLEDB;UID=ourUserID;Password=ourPassword;Initial Catalog=ourCatalog;Data Source=ourdatabasename and location)
Should in fact be this:-
Code: Select all
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionTimeout = 30
conn.CommandTimeout = 30
conn.Open ("Provider=SQLOLEDB;UID=ourUserID;Password=ourPassword;Initial Catalog=ourCatalog;Data Source=ourdatabasename and location")
As d3mon says, you want to make sure it is going to run on the server, and not the client. Use Runat="server" in your script tag.
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
  #6 (permalink)  
Old Apr 23rd, 2004, 16:36
Reputable Member
Join Date: Aug 2003
Location: United Kingdom
Posts: 341
Thanks: 0
Thanked 0 Times in 0 Posts
if you use Runat="server" though, you won't be able to use a msgbox...
  #7 (permalink)  
Old Apr 26th, 2004, 17:05
New Member
Join Date: Apr 2004
Location: Canada
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks

<blockquote id="quote"><font size="1" face="geneva, verdana, arial" id="quote">quote:<hr height="1" noshade id="quote">Originally posted by D3mon

if you use Runat="server" though, you won't be able to use a msgbox...
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">
Closed Thread

Tags
help, asp, procedure, vbscript

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Update two tables using Stored Procedure in SQL Wheatus7 Databases 5 Jul 1st, 2007 17:42
VBScript Hell moojoo Other Programming Languages 1 Oct 10th, 2006 20:44
URLDecode - The one - ASP/VBScript spinal007 Classic ASP 0 Aug 9th, 2006 13:41
VBScript.... courtjester Classic ASP 3 Feb 3rd, 2004 09:13


All times are GMT. The time now is 20:51.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43