Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP and Access 2

Status
Not open for further replies.

jguy

IS-IT--Management
Nov 17, 2000
69
0
0
US
Hello, I have a current project that I'm working on that uses Access DBs to store data in. I actually completed the project, but the company wanted to add this function to the site, so if anyone can help, then I will succeed, if not, then..... Anyway, here is the problem. I have a db called customers that simply houses a customers "routing code" and a hyperlink to their login page (each customer has a different login page according to who they are). On the main page, I have a text box and a submit button that they can enter their company code in to and then ASP should(I hope) redirect them to the hyperlink that is stored in the db along with their code. Anyway, I have no idea where and how to do this. I suppose that we would use the response.redirect command, but putting this into action poses a challenge to me. If anyone could help, it would be greatly appreciated. Thank you in advance.
I have included my work so far listed below with some of the errors that I get.



Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error in string in query expression 'custcode = '1dc2'.
/pictures/redirectcustomer.asp, line 17

Here's the code(we needed to add a ' to it):
<%
'connection string
Dim objCONN
dim objRS
dim strSQL
dim strURL

Set objCONN=Server.CreateObject(&quot;ADODB.Connection&quot;)
objCONN.Provider =&quot;Microsoft.Jet.OLEDB.4.0&quot;
objCONN.Open &quot;c:/db/pics/customers.mdb&quot;

strSQL=&quot;SELECT url FROM tblcustomer WHERE custcode = '&quot; & Request.Form(&quot;custcode&quot;)

set objRS=Server.CreateObject(&quot;ADODB.RecordSet&quot;)
objRS.Open strSQL,objCONN
strUrl=objRS(&quot;url&quot;)
set objRS=nothing
objCONN.Close
response.redirect(strUrl)
%>

we seem to be having a problem down at this line here &quot;objRS.Open strSQL,objCONN&quot;

 
the sql is wrong

In sql the variable that u r storing is not being closed
ur code
Code:
strSQL=&quot;SELECT url FROM tblcustomer WHERE custcode = '&quot; &
                          Request.Form(&quot;custcode&quot;)

the code should be
Code:
strSQL=&quot;SELECT url FROM tblcustomer WHERE custcode = '&quot; &
                          Request.Form(&quot;custcode&quot;) & &quot;';&quot;

hope this helps
Regards ::) Unicorn11
abhishek@tripmedia.com

[red]Nothing is permanent in life except Change[red]
 
I agree with unicorn11. Also, try using a variable to store the value of Request.Form(&quot;custcode&quot;). This would eliminate the confusion with internal quotation marks.
joeyh
 
Thank you guys so much! That solved the problem that I was having. I hope that I can contribute just as you guys did for me in the future. Thanks a million!
:)I &quot;now I'm educated!&quot;
Joe
 
Now that we have the SQL working right, how do I place a custom msg to an incorrect password or redirect to a custom htm page using the response.write or response.redirect method? I promise that this will be the last of the questions! :) Thanks..
 
You should try to avoid the Response.redirect since not all browser support it. Use Response.write instead.
You may want to keep in mind also that an Access Database can only support 30 concurrent connections so if this site is going to get significant traffic then it should be moved to SQL Server or another Database Server.


Wushutwist


Sun Certified Java 2 Programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top