Hi there,
I can't seem to find the proper syntax for my if statement when I have a list of links and depending on which link the administrator selects the mysql table will show up on the page it is redirected to.
All my links will be redirected to the same page, but I need to put in several if statements that I thought would be quite easy, but keep receiving syntax errors.
Here's my code if you can see the problem:
<%Dim conn
'Create an ADODB connection
Set conn = Server.CreateObject("ADODB.Connection")
'Open the database
conn.Open "Driver={MySQL ODBC 3.51 Driver};Server=24.79.93.78;Database=communitycentr e;UID=mona.ramsay;PWD=puke_9;"
'Execute the SQL and assign to our Recordset
set rs = Server.createobject("ADODB.recordset")
If selected = <a href="http://localhost/ValourCommunityCentre/PageItems.asp"><strong><span style="font-size: 16pt">
Community Club Table</span></strong></a><br /> then
sql = "SELECT * FROM CCtable"
end if
If selected = <a href="http://localhost/ValourCommunityCentre/PageItems.asp"><strong><span style="font-size: 16pt">
User Table</span></strong></a><br /> then
sql = "SELECT * FROM Usertable"
end if
<br />
rs.Open sql, conn
Any help would be appreciated.
M
9 1857
Your links should be more link this. Because you need to be passing a parameter.
[HTML]<a href="http://localhost/ValourCommunityCentre/PageItems.asp?LinkChosen=club"> Community Club</a>
<a href="http://localhost/ValourCommunityCentre/PageItems.asp?LinkChosen=user"> Users</a>
[/HTML]
Then you request.querystring the "LinkChosenValue" -
Dim selected, query
-
' get the item that was passed in the querystring.
-
selected = Request.QueryString("LinkChosen");
-
-
' i assumed you would have more than 1 or 2 links
-
Select Case selected
-
Case "club"
-
query = "SELECT * FROM CCtable"
-
Case "user"
-
query = "SELECT * FROM UserTable"
-
Case Else
-
query = ""
-
End Select
-
Hi there,
I changed my code, but now I keep receiving an error for my response.write code. It worked before, but now I receive the error.
Expected statement
/ValourCommunityCentre/PageItems.asp, line 56
<td> Response.write(x.value)</td>
This is my code:
<%Dim selected, query
' get the item that was passed in the querystring.
selected = Request.QueryString("LinkChosen")
' i assumed you would have more than 1 or 2 links
Select Case selected
Case "club"
query = "SELECT * FROM CCtable"
Case "user"
query = "SELECT * FROM UserTable"
Case Else
query = ""
End Select%>
<% rs.Open sql, conn%>
<table border="1" width="100%">
<tr>
<% for each x in rs.fields
response.write("<th>" & x.name & " </th>")
next%>
</tr>
<% do until rs.EOF
for each x in rs.fields%>
<%<td> Response.write(x.value)</td>%>
<%next
rs.movenext
loop
rs.close
conn.close
%>
</table>
I think it has something to do with my asp tags, but can't figure it out.
Try -
<%
-
Response.Write "<td>" & x.value & "</td>"
-
%>
-
Hello,
I keep receiving an error message when I select a link it is supposed to redirect to a pageitems.asp. I will have several links, but am just testing two right now.
I am using the select caes code, but keep receiving this error:
Error Type:
ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/ValourCommunityCentre/PageItems.asp, line 28
Here is my code:
<%Dim conn
'Create an ADODB connection
Set conn = Server.CreateObject("ADODB.Connection")
'Open the database
conn.Open "Driver={MySQL ODBC 3.51 Driver};Server=24.79.93.78;Database=communitycentr e;UID=mona.ramsay;PWD=puke_9;"
'Execute the SQL and assign to our Recordset
set rs = Server.createobject("ADODB.recordset")%>
<%Dim selected, query
' get the item that was passed in the querystring.
selected = Request.QueryString("LinkChosen")
rs.Open sql, conn
' i assumed you would have more than 1 or 2 links
Select Case selected
Case "club"
query = "SELECT * FROM CCtable"
Case "user"
query = "SELECT * FROM UserTable"
Case Else
query = ""
End Select%>
<table border="1" width="100%">
<tr>
<% for each x in rs.fields
response.write("<th>" & x.name & " </th>")
next%>
</tr>
<% do until rs.EOF%>
<tr>
<%for each x in rs.fields
Response.Write "<td>" & x.value & "</td>"%>
<% next
rs.movenext%>
</tr>
<%loop
rs.close
conn.close
%>
</table>
Could someone please take a look at it and see why I keep receiving the error??
I've gotten over other errors, but can't seem to figure this one out.
Thanks,
Mona
- rs.Open sql, conn
-
-
' i assumed you would have more than 1 or 2 links
-
Select Case selected
-
Case "club"
-
query = "SELECT * FROM CCtable"
-
Case "user"
-
query = "SELECT * FROM UserTable"
-
Case Else
-
query = ""
-
End Select%>
-
Well, you are doing an rs.Open sql, conn but sql does not appear anywhere in the code you provided. I would think you really mean rs.Open query, conn. But you would need to put that after the Select Case, else it is an empty variable.
Hi there,
I am still having problems with errors and can't display my page.
Now, I receive this error. I tried to debug, but can't figure it out.
ADODB.Recordset (0x800A0E78)
Operation is not allowed when the object is closed.
My code:
<%Dim conn
'Create an ADODB connection
Set conn = Server.CreateObject("ADODB.Connection")
'Open the database
conn.Open "Driver={MySQL ODBC 3.51 Driver};Server=24.79.93.78;Database=communitycentr e;UID=mona.ramsay;PWD=puke_9;"
'Execute the SQL and assign to our Recordset
set rs = Server.createobject("ADODB.recordset")%>
rs.Open query, conn
<%Dim selected, query
' get the item that was passed in the querystring.
selected = Request.QueryString("LinkChosen")
' i assumed you would have more than 1 or 2 links
Select Case selected
Case "club"
query = "SELECT * FROM CCtable"
Case "user"
query = "SELECT * FROM UserTable"
Case Else
query = ""
End Select%>
<table border="1" width="100%">
<tr>
<% for each x in rs.fields
response.write("<th>" & x.name & " </th>")
next%>
</tr>
<% do until rs.EOF%>
<tr>
<%for each x in rs.fields
Response.Write "<td>" & x.value & "</td>"%>
<% next
rs.movenext%>
</tr>
<%loop%>
<%rs.close
conn.close
%>
<%Dim conn
'Create an ADODB connection
Set conn = Server.CreateObject("ADODB.Connection")
'Open the database
conn.Open "Driver={MySQL ODBC 3.51 Driver};Server=24.79.93.78;Database=communitycentr e;UID=mona.ramsay;PWD=puke_9;"
'Execute the SQL and assign to our Recordset
set rs = Server.createobject("ADODB.recordset")%>
rs.Open query, conn
<%Dim selected, query
' get the item that was passed in the querystring.
selected = Request.QueryString("LinkChosen")
Where is your query?
You open a connection object, then set your recordset object and open it with "query" - but "query" is set with Select Case AFTER you open your recordset. Execution of an ASP page happens from top to bottom, like you would read a book. So at the point in time that you are trying to open your recordset object "query" is null, or equal to "" - therefore you are passing an invalid, or empty, query to your database. Your recordset doesn't get opened. -
<%
-
Dim conn
-
'Create an ADODB connection
-
Set conn = Server.CreateObject("ADODB.Connection")
-
-
'Open the database
-
conn.Open "Driver={MySQL ODBC 3.51 Driver};Server=24.79.93.78;Database=communitycentr e;UID=mona.ramsay;PWD=puke_9;"
-
-
'Execute the SQL and assign to our Recordset
-
set rs = Server.createobject("ADODB.recordset")%>
-
-
Dim selected, query
-
' get the item that was passed in the querystring.
-
selected = Request.QueryString("LinkChosen")
-
-
' i assumed you would have more than 1 or 2 links
-
Select Case selected
-
Case "club"
-
query = "SELECT * FROM CCtable"
-
Case "user"
-
query = "SELECT * FROM UserTable"
-
Case Else
-
query = ""
-
End Select
-
-
rs.Open query, conn
-
-
%>
-
-
I moved your recordset open statement to AFTER the query string variable is set. So...
1) your connection object is created
2) your connection object is opened
3) your recordset object is created
4) your query is set, depending on what url the visitor selected
5) your recordset object is opened and your query is passed into it to grab information from the database.
Mark
Hi there,
I moved my open recordset and it worked.
Thank you very much.
Mona
I recently had to use a select statement with 40 different outcomes where on analysis of what came back from the database I fed differing strings into a variable which displayed different buttons going to different pages displaying different messages on hover over the button. I also fed variables into the variable itself . Worked really well, let me know if you would like the code.
Steve M
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Colleyville Alan |
last post by:
I have an application that has an Access table that stores the locations of
slides in a Powerpoint file. This used to work fine when there were about 4
files and 200 slides. The database would...
|
by: Seefor |
last post by:
Hi, I want my text hyperlinks to have a dotted border underneath, so I did
this which works fine:
a,
a:link,
a:visited,
a:hover,
a:active {
color: #000;
text-decoration: none;
|
by: Robin |
last post by:
Hello!
I'm having trouble with links and hyperlinks in MS Access 2003 - any
help would be great!
Question 1!
The "insert hyperlink" icon opens a browser window, allows the user to
browse...
|
by: Janna |
last post by:
Hello tech savvy gurus! I hope someone can help me!
THE PROBLEM:
"Cannot open specified file" when I click on a hyperlink in an Access database when it is located on our server.
THE...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |