Hi;
Thanks for the response. Let me give you a little more background as to what
I'm trying to do. I have a very simple MS Access database consisting of three
fields: username, password and stylesheet. What I want to do is allow a user
to input their username and password into a form (I'm using Frontpage) and
retrieve the associated style sheet which has specific rules. This
stylesheet will be passed to a browser so that the webpage will follow the
rules in the stylesheet. For example, if Tom (username:tom and password:mot)
inputs his info into the form, his stylesheet variable value (tom.css) will
be attached to the webpage I want to launch.
After the sqlstr variable is created, I have the following code:
// connection string construction
var strConn = "Driver={Microsoft Access Driver
(*.mdb)};DBQ=" + Server.MapPath("users.mdb");
// connection object creation
var dbConn = Server.CreateObject("ADODB.Connection");
// open the connection
dbConn.Open(strConn);
// Execute the query with constructed SQLstr
var rs = dbConn.Execute(SQLstr);
}
I want the variable rs to capture the stylesheet variable value and then
pass it to the page in the url like:
<a href="nextpage.asp?styles=<% rs %>"
and link it to the page to be launched like:
<link rel="stylesheet" type="text/css" href="/styles/<%=
request.querystring(styles) %>" media="screen">
In accordance with your recommendations, I changed my SELECT statement to:
SQLstr = "SELECT [stylesheet] FROM userinfo WHERE
(([username] = '" & user_form!username & "') AND
([password] = '" & user_form!password & "'));"
But I still get the same unterminated string constant error at line 22
column 51 which is at the very end of the second line . Any other ideas are
welcome.
Klatuu said:
There are a couple of problems here.
1. The ; is in the wrong place.
2. The + in Access is a math symbol. Always use & when concatenating strings
3. The syntax for addressing a form is incorrect. The . is used for defined
objects, methods, and properties. The ! is used for User defined objects.
4. I am suspicious of document.user_form.username Even with the ! replacing
the . the format is incorrect. To address a control on a form in Access,
there are two methods. One method is for code in a form's module:
Me.MyControlName
The other is for addressing a control from another module:
forms!MyFormName!MyControlName
5. Although the .Value is correct, it is not necessary. It is the defaut
property returned. If you were to use it, the correct syntax is:
forms!MyFormName!MyControlName.value
Notice the . instead of the ! That is because Value is a property of a
control.
So, I don't know what document is here, so I can't completely resolve this.
Hopefully I have given you enough info to clean it up.
SQLstr = "SELECT [stylesheet] FROM userinfo WHERE
(([username] = '" & document!user_form!username & "') AND
([password] = '" & document!user_form!password & "'));"
jjfjr said:
Hi;
I'm creating some javascript code in frontpage so that I can retrieve some
info from an MS Access database. The database has three fields: username,
password and stylesheet. I'm trying to retrieve the stylesheet value by
having a user input their username and password in a form. I then create a
SQL SELECT statement with the following code:
SQLstr = "SELECT [stylesheet] FROM userinfo WHERE
(([username] = '" + document.user_form.username.value + "') AND
([password] = '" + document.user_form.password.value + "'))";
When problem-free this will be used to access the info from the database via
a connection string. When I try to run the form page , I get an error that
says "Unterminated string constant line 22 column 51" . Line 22 column 51 is
the character v in value in the second line. I'm little a new to javascript
and not used to mixing single and double quotes; I had gotten this code from
reading some texts. Any help is greatly appreciated.