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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select * from Variable

Status
Not open for further replies.

Dashsa

Programmer
Joined
Aug 7, 2006
Messages
110
Location
US
Hello,
I have a few tables that uses access, I am working on allowing them to edit the data. I have a page that allows the user to select which data they want to edit now I need to choose the table that contains the data.

Below is the code I have that is failing.
Code:
%@ language=JScript %>
<!-- #include file="adojavas.inc" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Form Choice</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<%
var table = Request.form("table");
var umail = Session("Umail")

var connect = Server.CreateObject("ADODB.Connection");
var record = Server.CreateObject("ADODB.RecordSet");
connect.Open("DSN=hhhba");
record.Open("select * from " +table+" where EmailAddress ='"+umail+"'", connect, adOpenKeyset,adLockOptimistic);

%>
</head>
<body>
<center>

</center>
</body>
</html>
as you can see I am getting the table name form a form on the prvious page. Is is possible to choose the table from a variable?
Code:
record.Open("select * from " +table+" where EmailAddress ='"+umail+"'", connect, adOpenKeyset,adLockOptimistic);


Thanks
 
There is no reason why this shouldn't work since the SQL statement is being resolved with the actual table name. Did you try it? Is it not working?

Duane
Hook'D on Access
MS Access MVP
 
Yeah its working now.
I did not change anything-
weird...
Thanks for looking
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top