View Full Version : Simple ASP and database question. Please help.
artsapimp
08-06-2000, 09:12 AM
Believe it or not I am now a webmaster/asp programmer. I am not good at asp yet, but I'm learning as I go along. Most of my asp work is done to connect to an access database and grab basic information, update it, or add new records. I am still having some basic problems and was hoping someone could go to...
http://www.vbforums.com/showthread.php?threadid=25474
... and see if they know either answer. Thank you very much for any help.
------------------
If you think an education is expensive...try ignorance.
UncaDanno
08-06-2000, 03:55 PM
Assuming you have all these controls in a form, you could do the following for the select/text duo:
As you process the "request.form" fields, you could build your SQL statement for accessing Access like this:
strSQL = "select (whatever you're going to select) from (whatever the table name is) where " & request.form("search") & " = """ & request.form("criteria") & """"
Yeah. There's those dang triple- and quad-quotes again.
For the checkboxes, I'm not sure about what you're trying to do, but here's a stab at it.
Are you storing whether the user checked a box to the database? Easiest way to do this would be to use a 1 or 0 like parksie suggested. Then, when you retrieved the data, you could "check" a box like this:
Dim strChk629
Dim strChk691
strChk629 = "" (just for insurance)
strChk691 = "" (ditto)
...... getcher data right here, folks .....
if Err629 = 1 then
strChk629 = " checked "
end if
if Err691 = 1 then
strChk691 = " checked "
end if
Note: the above assumes you store the state of the checkboxes in separate fields. If you store the error number (629 or 691) in a single field and want to check the appropriate box, you can say:
select case ErrorCode
case 629
strChk629 = " ""checked"" "
case 692
strChk691 = " ""checked"" "
end select
Then the code for your checkboxes would look like this:
<input type="checkbox" name="error" value="629" <%=strChk629%>>Error 629</input>
<input type="checkbox" name="error" value="691" <%=strChk691%>>Error 691</input>
That should set the state of the checkboxes.
[This message has been edited by UncaDanno (edited 08-06-2000).]
Dang ol symbols.....
[This message has been edited by UncaDanno (edited 08-06-2000).]
artsapimp
08-06-2000, 04:12 PM
That is perfect. Thank you.
I tried to set up the search statically because it made sense that I could write...
strSQL = "SELECT * FROM artsapimp where name = art", conn
That didn't work for some reason. I tried to substitute the end with the autonumber ID and search by that and it worked fine. This is that line.
strSQL = SELECT * FROM artsapimp where ID = 1", conn
That was fine. Does the autonumber part matter? That is the only difference.
Thanks for your help.
------------------
If you think an education is expensive...try ignorance.
UncaDanno
08-07-2000, 04:00 AM
The difference is that, autonumber being numeric, you don't need quotes around its value in your SQL select statement. Since name is a string, you do need quotes around its value in the SQL statement.
And remember that, if you are accessing most any other database (SQL, Oracle, etc), you need single instead of double quotes around string values.
artsapimp
08-07-2000, 05:42 AM
That makes sense. Thank you very much.
------------------
If you think an education is expensive...try ignorance.
vBulletin® v3.7.0, Copyright ©2000-2008, Jelsoft Enterprises Ltd.