PDA

View Full Version : need help in passing variable value


mahesh_r_blr
04-07-2005, 08:03 PM
Hi ,

i am new to asp and doing some basic scripts to get to know it better. i need some help to know how to pass a date variable value to a sql query in a asp scipt. the script is as follows:

<html>

<head>
<!-- #INCLUDE FILE = "ADOVBS.INC" -->
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>sales shseet</title>
</head>

<body>


<%
dim a,b

a = request.form("txt1")
b = request.form("txt2")
dim con
Set con = Server.CreateObject("ADODB.CONNECTION")
con.Open "dialer2","dialer2","dialer2"

dim rs
set rs =Server.CreateObject("ADODB.Recordset")

strQuery = "SELECT * FROM call_log where disposition='sale' and logdate between ('a') and ('b')"

Set rscall_log = Con.Execute(strQuery)

If Not rscall_log.BOF Then
%>
<TABLE>

<%
Do While Not rscall_log.EOF

rscall_log.MoveNext
Loop
%>
</TABLE>
<%
Else
Response.Write("Sorry, no data found.")

End If
%>





<%
rscall_log.Close
Con.Close

Set Con = Nothing
Set rscall_log = Nothing
%>
<p></p>
<p><nobr></nobr></p>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" startspan U-File="../_private/form_results.txt"
S-Format="TEXT/CSV" S-Label-Fields="TRUE" --><input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!--webbot
bot="SaveResults" endspan -->
<p><input type="text" name="txt1" size="20"><input type="submit" name="s1"></p>
</form>
</body>

</html>


please let me know how to pass the values a and b from a form to the query so that i can get all the info from the sql table

Thanks,

Mahesh

glenngv
04-08-2005, 05:50 AM
strQuery = "SELECT * FROM call_log where disposition='sale' and logdate between '" & a & "' and '" & b & "'"

You are just concatenating strings and variables that will form as the SQL query and & operator is used for that.

mahesh_r_blr
04-12-2005, 07:43 AM
Hi,

i have incorporated the statement into the script, but i am facing some db conenction problems ......like

Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'rscall_log'
/ss/sqlq23.asp, line 71

this i think is due to the script not able to update the db table. just trying to check out where the problem lies now...

will post back a reply when this is resolved...

Thanks,

Mahesh

miranda
04-12-2005, 08:04 AM
Your error says your variable does not match the datatype of a database column. Loking at your code I can't tell if it is an Access database or a SQL Server database. If this is an Access database you need to show the query like so
strQuery = "SELECT * FROM call_log WHERE disposition='sale' AND logdate BETWEEN #" & a & "# AND #" & b & "#"

mahesh_r_blr
04-12-2005, 10:34 AM
Hi ,

now i think the variables are geting passed , as i am able to see the from and to feilds in the asp page when i execute the script......but i am geting the

HTTP 404 - File not found Internet Information Services this hapens when i change the post to get in submit form properties


HTTP 405 - Resource not allowed Internet Information Services this hapens when i change the get to post in submit form properties

right now i am checking google for some info regarding this..

Will keep posted on developments.....

Thanks,

Mahesh

mahesh_r_blr
04-12-2005, 04:04 PM
Hi,

i am stuck with this 404 and 405 error..

tried searching the web for info..

this is what i got for 405----
Cause
The file type is not registered in the IIS script map settings (e.g. .html or .htm). IIS 5.1 only allows HTTP requests of type to GET to unmapped files. HTTP requests of type POST, HEAD, and all others are responded to with a 405 resource not allowed error.

As a security note, you should always remove unused script mappings. This is the default behavior of IIS 6, which will only serve named extensions and refuse all others.

Resolution
Add a script map for the extension. A script map associates a particular file type with a given script module. The web server runs the module on the given file and sends the output to the browser, instead of sending the file directly to the browser.

Go to "Control Panel"-"Administrative Tools"-"Internet Information Services".
Expand the tree to "COMPUTERNAME"-"Web Sites"-"Default Web Site".
Right-click on "Default Web Site" and select "Properties". (Alternately, select "Default Web Site" and press Alt+Enter.)
Select the "Home Directory" tab.
Click the "Configuration" button.
From the "Mappings" tab, select the "Add" button.
Click the "Browse..." button, choose "Dynamic Link Libraries *.dll" from the "Files of Type" dropdown, and select c:\WINDOWS\System32\inetsrv\asp.dll.
Type ".html" (without quotes) in the "Extension" box.
Select the "Limit to:" radio button, and type in "GET, POST" (without quotes) in the box next to it.
Click the "OK" button and close all the dialogs. (If the "OK" button is greyed out, then make sure all the entries are correct and try clicking in the file name box.)
See the screen shot below. You must adjust the above instructions to your particular OS, web site configuration, and file type. You can associate the file type with a different script engine besides asp.dll, which is the ASP 3.0 script engine. There is no need to give IWAM_COMPUTERNAME permission to the file, only IUSR_COMPUTERNAME needs NTFS read and execute permission.






from here i am in a fix where to go about...

Mahesh

miranda
04-12-2005, 05:41 PM
405 errors on the screen are displayed as "Friendly error messages" unless you turn them off. To debug an ASP application you need to remove friendly error handling. To do this in Internet Explorer click on Tools, next click on Internet Options now click on the Advanced tab scroll down to where it says "Show friendly HTTP error messages" uncheck this and then click Apply, now click OK. Now try to run your code. You will see the actual errror produced.

404 Errors are file Not Found, meaning that the file is not on the server. This could be due to a typographical error when you entered it in the address bar, or the link pointing to the file is in error.

mahesh_r_blr
04-27-2005, 07:37 PM
Hi,

have got over the 404 and 405 errors now.... i am getting the results from the sql db table also .....but the date and time which i pass into the "from" and "to" forms are not getting validated properly....the results which i get are not between the date and time mentioned in the from and to feilds.

let me explain....i pass the value 04/25/2005 10:00:00am in "from" and 04/26/2005 01:30:00pm in "to" form.

the records / result which i should get typically should be between this date and time range. But this is not happenning.....records of dates after and before the dates are getting generated...

so the question is ----is there a validation in the text box properties to be done so that this date and time gets passed corerctly...


thanks,
Mahesh