Whing Dela Cruz
asked on
Obtaining data on ASP
I am trying to obtain data using directly to my page html via ASP <%%> as the code shown below. However, the codes had an error says, "expected end of statement"
<!DOCTYPE html>
<html>
<body>
<h1>My First Display</h1>
<%
Dim cn
Dim rs
Dim filePath
filePath = "C:\MyDb\DbUsers.accdb"
Set cn = Server.CreateObject("ADODB .Connectio n")
cn.Open ("Provider=Microsoft.ACE.O LEDB.12.0. 1; Data Source=" & filePath & "; Persist Security Info=False; Jet OLEDB:Database Password=iErwin")
rs.Open "Select UserCode, UserName, TelNumber from MyUsers", conn
with rs
If not .BOF = True And not .EOF = True Then
var x = .Fields("UserName");
alert("x");
response.write "Your order has been sent!"
else
alert("No record!");
End If
end with
rs.close
cn.close
%>
</body>
</html>
erro1.bmp
<!DOCTYPE html>
<html>
<body>
<h1>My First Display</h1>
<%
Dim cn
Dim rs
Dim filePath
filePath = "C:\MyDb\DbUsers.accdb"
Set cn = Server.CreateObject("ADODB
cn.Open ("Provider=Microsoft.ACE.O
rs.Open "Select UserCode, UserName, TelNumber from MyUsers", conn
with rs
If not .BOF = True And not .EOF = True Then
var x = .Fields("UserName");
alert("x");
response.write "Your order has been sent!"
else
alert("No record!");
End If
end with
rs.close
cn.close
%>
</body>
</html>
erro1.bmp
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I can't figure out which part of your solutions running wrong. I'm still want to know and pursue your solution in spite of having this formula.and too quick for my comment!
var x = .Fields("UserName")
is invalid and should be as:
x = .Fields("UserName")
var is for javascript!
ASKER
An error says, Micro. VBScript runtime.. Object required. That's the error while removing var..
try:
Dim x
x = .Fields("UserName")
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you both of you sirs!
ASKER
<!DOCTYPE html>
<html>
<body>
<h1>My First Display</h1>
<%
Dim connStr, objConn
Dim filePath
filePath = "C:\MyDb\DbUsers.accdb"
Set objConn = Server.CreateObject("ADODB
objConn.Open ("Provider=Microsoft.ACE.O
Set rs = objConn.execute("Select UserCode, UserName, TelNumber, iPassword from MyUsers where iPassword='i100' ")
with rs
If not .BOF = True And not .EOF = True Then
response.write (.Fields("UserName"))
response.write (.Fields("TelNumber"))
else
response.write "No record!"
End If
end with
rs.close
objConn.close
%>
</body>
</html>