bcarrolluk
asked on
How do I Run a SQL Query in ASP?
Ok, so far i have this
------
Ok so what i need is for some way to take the data that the is entered into the text box at the top of the page and then run it in the SQL query, the query just searches for that phonenumber and brings back the number and the operator.
Then once i have that, i need it to write the Phonenumber and the Operator into a table..
Any help is appreciated :)
------
Ok so what i need is for some way to take the data that the is entered into the text box at the top of the page and then run it in the SQL query, the query just searches for that phonenumber and brings back the number and the operator.
Then once i have that, i need it to write the Phonenumber and the Operator into a table..
Any help is appreciated :)
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CPS LCR Customer List</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<label>
<input type="text" name="Text" id="Text" />
Please Enter the CPS / LCR Number</label>
</form>
<%
if len(request.form("Text")) <> "11" then
response.write("Error - Please Enter an 11 Digit Number")
else
response.write("")
end if
set Con = Server.CreateObject("ADODB.Connection")
con.open "File Name=" & Server.MapPath("EbillzSQL.UDL")
SQL = "SELECT CustomerIdentifier, Operator From LCRCustList Where CustomerIdentifier = '" & request.form("Text")& "'"
ASKER
OK i ran that and i got this error
Microsoft VBScript runtime error '800a01a8'
Object required: ''
/JamesH/LCRCustList.asp, line 32
The Code now looks like this --
Microsoft VBScript runtime error '800a01a8'
Object required: ''
/JamesH/LCRCustList.asp, line 32
The Code now looks like this --
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CPS LCR Customer List</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<label>
<input type="text" name="Text" id="Text" />
Please Enter the CPS / LCR Number</label>
</form>
<%
if len(request.form("Text")) <> "11" then
response.write("Error - Please Enter an 11 Digit Number")
else
response.write("")
end if
set Con = Server.CreateObject("ADODB.Connection")
con.open "File Name=" & Server.MapPath("EbillzSQL.UDL")
sql = "SELECT CustomerIdentifier, Operator From LCRCustList Where CustomerIdentifier = '" & request.form("Text")& "'"
set rs = conn.execute(sql)
response.write "<table>"
response.write "<tr><th>CustomerIdentifier</th><th>Operator</th></tr>"
while not rs.eof
response.write "<tr><td>" & rs.fields("CustomerIdentifier").value & "</td><td>" & rs.fields("Operator").value & "</td></tr>"
rs.movenext
wend
response.write "</table>"
rs.close
%>
</body>
</html>
<form id="form1" name="form1" method="post" action="thenameofthissamep age.asp">
<label>
<input type="text" name="phonebox" id="Text" />
Please Enter the CPS / LCR Number</label>
</form>
<%
set Con = Server.CreateObject("ADODB .Connectio n")
con.open "File Name=" & Server.MapPath("EbillzSQL. UDL")
if len(request.form("Text")) <> 11 then
response.write("Error - Please Enter an 11 Digit Number")
else
phbox = Replace(Request.Form("phon ebox"),"'" ,"''")
' response.write("")
SQL = "SELECT CustomerIdentifier, Operator From LCRCustList Where phonenumberfieldname = '" & phbox & "'"
rs.Open SQL,con
end if
<label>
<input type="text" name="phonebox" id="Text" />
Please Enter the CPS / LCR Number</label>
</form>
<%
set Con = Server.CreateObject("ADODB
con.open "File Name=" & Server.MapPath("EbillzSQL.
if len(request.form("Text")) <> 11 then
response.write("Error - Please Enter an 11 Digit Number")
else
phbox = Replace(Request.Form("phon
' response.write("")
SQL = "SELECT CustomerIdentifier, Operator From LCRCustList Where phonenumberfieldname = '" & phbox & "'"
rs.Open SQL,con
end if
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thats brilliant
Cheers
Cheers
ASKER
Awesome
Open in new window