PDA

View Full Version : request.form


turnknuckle
11-05-2002, 10:37 PM
Greetings

Im having a problem posting a values/s from a form to an asp script; if i give the script a literal value for strFirmType ie. strFirmType = "Stock Finance" it connects to the db fine and displays the records, but when i try to get a value for strFirmType from my form it gives me:

ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
and points to the line that reads: RS.Open strSQL, strCon


Any Ideas???
Turnknuckle...

<form name "search_form" method = "post" action = "simpler_search.asp">




Set DB = Server.CreateObject ("ADODB.Connection")

strCon = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("fin_prov.mdb")

strFirmType = Request.Form("firm_type")
DB.Open strCon

Set RS = Server.CreateObject ("ADODB.Recordset")

If strFirmType = "Stock Finance" Then
strSQL = "SELECT * FROM stock_finance;"
End if


RS.Open strSQL, strCon

If RS.EOF And RS.BOF Then
Response.Write "no records"
Else

Do While not RS.EOF

Response.Write ("<br>")
Response.Write ("<b>company: </b>")
Response.Write (RS("company"))
Response.Write ("<br>")
Response.Write ("<b>contact: </b>")
Response.Write (RS("contact"))
Response.Write ("<br>")
Response.Write ("<b>tel_number: </b>")
Response.Write (RS("tel_number"))
Response.Write ("<br>")
Response.Write ("<b>address: </b>")
Response.Write (RS("address"))
Response.Write ("<br>")
Response.Write ("<b>Email: </b>")
Response.Write (RS("email"))
Response.Write ("<br>")
Response.Write ("<b>web: </b>")
Response.Write (RS("web"))
Response.Write ("<br>")
Response.Write ("<b>min_invest: </b>")
Response.Write (RS("min_invest"))
Response.Write ("<br>")
Response.Write ("<b>max_invest: </b>")
Response.Write (RS("max_invest"))
Response.Write ("<br>")
Response.Write ("<b>firm_type: </b>")
Response.Write (RS("firm_type"))
Response.Write ("<br>")
Response.Write ("<b>ind_pref: </b>")
Response.Write (RS("ind_pref"))
Response.Write ("<br>")
Response.Write ("<b>geog_pref: </b>")
Response.Write (RS("geog_pref"))

Response.Write ("<br>")
Response.Write ("<br>")

'Move to the next record in the recordset
RS.MoveNext

Loop
End if

turnknuckle
11-05-2002, 11:04 PM
My Apologies!
I was being a dunce. - i declared the strFirmType variable when i didn't have to and that was tweaking the script out...
/dont bother replying!
turn.:D

whammy
11-06-2002, 12:51 AM
Hmm... glad you solved it, but your answer to how you solved the problem wasn't clear. At any rate, it was probably a common mistake(?).

Declaring a variable shouldn't cause a problem. Can you clarify further for everyone else's enlightenment? Don't worry, we all make mistakes. :D

Were you perhaps looking for the variable without saying:

strFirmType = Request.Form("strFirmType")

?

I don't know how many times I've done that, but if you use:

<% Option Explicit %>

after your page language tag, it should help you out a lot with that, sinces it forces you to Dimension (declare) every variable. :D

glenngv
11-06-2002, 02:54 AM
and there may be times that strSQL will be empty if strFirmType is not equal to "Stock Finance". Maybe that was the cause of the error you encountered, there's no SQL statement to execute.

strFirmType = Request.Form("firm_type")
DB.Open strCon
Set RS = Server.CreateObject ("ADODB.Recordset")
If strFirmType = "Stock Finance" Then
strSQL = "SELECT * FROM stock_finance;"
End if

RS.Open strSQL, strCon


you may want to move the End if at the bottom of the code.

turnknuckle
11-06-2002, 07:51 AM
Yeah it is strange that taking out the declaration fixed the problem! but somehow it did...
I guess thats why i love programming - its a new challenge everyday.
Thanks for the responses guys! and i'll remember that 'option explicit' tip, thats something i completely forgot about after putting down my VB book after college!
Thanks
Turn