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

remove single quotes from string, asp will not read as text!!

Status
Not open for further replies.

401R

Programmer
Oct 31, 2001
23
US
I am been trying to figure this out for a while now and I have not found a solution. I'm sure it will something simple, but I want to move ahead with the project so I will ask the smart people of this list.

-I have a DB field that lists table names. Using ASP I tell it

Step_table_name = (Step_List.Fields.Item("Table_Name").Value)

-Then try to use that table name to pull data out from that table

<%=(Step_Table_Name.Fields.Item(&quot;Status&quot;).Value)%>

-The field for the table name on the DB is set as &quot;varchar&quot; so when I run the page ASP sees the table name as

'tblIncoming_Clean'

-So when I have

<%=(Step_Table_Name.Fields.Item(&quot;Status&quot;).Value)%>

-It sees it as

<%=('tblIncoming_Clean'.Fields.Item(&quot;Status&quot;).Value)%>

-I need to get rid of the single quotes.

-I tried doing a trim but when I trim it trims the &quot;t&quot; and the &quot;n&quot; skipping the single quotes

-This is what the error looks like in case I am intrepreting it wrong

Microsoft VBScript runtime (0x800A01A8)
Object required: 'tblIncoming_Clean' /spectra/TMP2phbel43ls.asp, line 181

-Line 181 is

<%=(Step_Table_Name.Fields.Item(&quot;Status&quot;).Value)%>

It is seeing tblIncoming_clean as a separate object instead of putting it together and using it as <%=(tblIncoming_Clean.Fields.Item(&quot;Status&quot;).Value)%>

I created the recordset for this on the page so it shouldn't be because it is not there.


Any suggetions are extemely appreciated if anyone would like to help.

Thank You
 
You open the database and get table names, you have that sorted.
Then when you open the other table your open statement should be something like this

tableName=Step_List.Fields.Item(&quot;Table_Name&quot;).Value
' You've already pulled this out

rs.open &quot;select * from &quot; & tableName,conn

This is very basic and you need to build it into your actual opening

 
I already have a recordset open statement at the top of the page. Do I need to have the loop create the recordset everytime?

This page will do this loop for 34 times for diferent tables and up to 20 times for different parts to track, would that cause problems opening recordset so many times?
Maybe not if I close every recordset each time it is used, but this will be process intensive.

 
Don't worry non taken, I don't consider myself and expert and I am always interested to learn more. Can I e-mail a text file?
 
I will post it here, but if it is too much we can find a different way. I appreciate the help.

I've added comments to what I am trying to accomplish. I have gotten a different version of this to work, but in the page there is code for each individual table to be displayed, if any changes are made to the tblstep_list, I will have to manually insert the code to display the step status on the webpage. This way I only need to add the recordset, but that can also be automated down the line, perhaps.

```````````````````````````````````````````````````````
<%@LANGUAGE=&quot;VBSCRIPT&quot; CODEPAGE=&quot;1252&quot;%>
<!--#include file=&quot;Connections/spectra_DB_3.asp&quot; -->

<%
Dim Wafer_Reg
Dim Wafer_Reg_numRows

Set Wafer_Reg = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Wafer_Reg.ActiveConnection = MM_spectra_DB_3_STRING
Wafer_Reg.Source = &quot;SELECT * FROM spectra_db_3.tblwafer_reg&quot;
Wafer_Reg.CursorType = 0
Wafer_Reg.CursorLocation = 2
Wafer_Reg.LockType = 1
Wafer_Reg.Open()

Wafer_Reg_numRows = 0

%>
<%
Dim Step_List
Dim Step_List_numRows

Set Step_List = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Step_List.ActiveConnection = MM_spectra_DB_3_STRING
Step_List.Source = &quot;SELECT * FROM spectra_db_3.tblstep_list&quot;
Step_List.CursorType = 0
Step_List.CursorLocation = 2
Step_List.LockType = 1
Step_List.Open()

Step_List_numRows = 0

%>
<%
Dim Membrane_Bond
Dim Membrane_Bond_numRows

Set Membrane_Bond = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Membrane_Bond.ActiveConnection = MM_spectra_DB_3_STRING
Membrane_Bond.Source = &quot;SELECT * FROM spectra_db_3.tblmembrane_bond&quot;
Membrane_Bond.CursorType = 0
Membrane_Bond.CursorLocation = 2
Membrane_Bond.LockType = 1
Membrane_Bond.Open()

Membrane_Bond_numRows = 0
%>
<%
Dim Membrane_Grind
Dim Membrane_Grind_numRows

Set Membrane_Grind = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Membrane_Grind.ActiveConnection = MM_spectra_DB_3_STRING
Membrane_Grind.Source = &quot;SELECT * FROM spectra_db_3.tblmembrane_grind&quot;
Membrane_Grind.CursorType = 0
Membrane_Grind.CursorLocation = 2
Membrane_Grind.LockType = 1
Membrane_Grind.Open()

Membrane_Grind_numRows = 0
%>
<%
Dim tblIncoming_Clean
Dim tblIncoming_Clean_numRows

Set tblIncoming_Clean = Server.CreateObject(&quot;ADODB.Recordset&quot;)
tblIncoming_Clean.ActiveConnection = MM_spectra_DB_3_STRING
tblIncoming_Clean.Source = &quot;SELECT * FROM spectra_db_3.tblincoming_clean&quot;
tblIncoming_Clean.CursorType = 0
tblIncoming_Clean.CursorLocation = 2
tblIncoming_Clean.LockType = 1
tblIncoming_Clean.Open()

tblIncoming_Clean_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
Wafer_Reg_numRows = Wafer_Reg_numRows + Repeat1__numRows
%>
<%
Dim Repeat2__numRows
Dim Repeat2__index

Repeat2__numRows = -1
Repeat2__index = 0
Step_List_numRows = Step_List_numRows + Repeat2__numRows
%>
<%
Dim Repeat3__numRows
Dim Repeat3__index

Repeat3__numRows = -1
Repeat3__index = 0
Step_List_numRows = Step_List_numRows + Repeat3__numRows
%>

<html>
<head>
<title>WIP Summary</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>

<body>
<img src=&quot;images/title_bar.gif&quot; width=&quot;500&quot; height=&quot;80&quot;>
<table width=&quot;102%&quot; border=&quot;0&quot; cellpadding=&quot;1&quot; cellspacing=&quot;3&quot;>
<tr>
<td width=&quot;310&quot;>&nbsp;</td>

' Display the list of all the steps in tblStep_list across the top of the page
<% While ((Repeat2__numRows <> 0) AND (NOT Step_List.EOF)) %>
<td width=&quot;630&quot;><font size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;><strong>
<a href=&quot;New_Record/<%=(Step_List.Fields.Item(&quot;New_rec&quot;).Value)%>&quot;>
<%=(Step_List.Fields.Item(&quot;Display_Name&quot;).Value)%>
</a>

</strong></font>
</td>
<%'End loop for Step_List
Repeat2__index=Repeat2__index+1
Repeat2__numRows=Repeat2__numRows-1
Step_List.MoveNext()
Wend





%>
</tr>


<%
While ((Repeat1__numRows <> 0) AND (NOT Wafer_Reg.EOF))
%>

<% 'Loop through tblWafer_reg to list all the wafer in Process
Dim Wafer_Loc

Wafer_Loc = (Wafer_Reg.Fields.Item(&quot;Wafer_ID&quot;).Value)

response.write &quot;<tr>&quot;

response.write &quot;<td width=&quot;&quot;150&quot;&quot;><font size=&quot;&quot;2&quot;&quot; face=&quot;&quot;Verdana, Arial, Helvetica, sans-serif&quot;&quot;><Strong>&quot; & Wafer_Loc & &quot;</Strong></font></td>&quot;


%>


<td width=&quot;630&quot;><font size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>
<%


' Loop through the tblstep_list, use the table name to create a loop to open each step table and
'display the status of each wafer for that table throughout all the steps.
'example:
' step 1 | step 2 | step 3 | step 4
'401-1 | status | statust| |
'501-2 | status | | |
'607-1 | status | status | status |

'there is loop to fill in the steps at the top and a separate loop to display the part numbers
'on the left which has a nested loop to go through all the table steps and pull out the status
'of each part at each step. This loop is to through and open each table and display the status
'for that part. I have not put in the function to look for the specific part number in each table
'I am trying to get the loop for the status to work first.
'
Step_List.MoveFirst()
Dim Step_table_name


Step_table_name = Step_List.Fields.Item(&quot;Table_Name&quot;).value


While ((Repeat3__numRows <> 0) AND (NOT Step_List.EOF))

%>

<a href=&quot;New_Record/<%=(Step_List.Fields.Item(&quot;New_rec&quot;).Value)%>&quot;>


<%
'use the current step name, insert into statement to view &quot;status&quot; field value
'on the table. This is where I get the error. %>

<% =(Step_table_name.fields.item(&quot;status&quot;).value)%> </a>

</font> </td>
<%'End loop for Step_List
Repeat3__index=Repeat2__index+1
Repeat3__numRows=Repeat2__numRows-1
Step_List.MoveNext()
Wend
%>


<% 'close wafer step and row of data
response.write &quot;</tr>&quot;
%>


<% 'repeat to display all parts in registration
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Wafer_Reg.MoveNext()
Wend
%>
</table>


</body>
</html>
<%
Wafer_Reg.Close()

Set Wafer_Reg = Nothing
%>
<%
Step_List.Close()

Set Step_List = Nothing
%>
<%
Membrane_Bond.Close()
Set Membrane_Bond = Nothing
%>
<%
Membrane_Grind.Close()
Set Membrane_Grind = Nothing
%>
<%
tblIncoming_Clean.Close()
Set tblIncoming_Clean = Nothing
%>

```````````````````````````````````

Thanks for taking a look..

Jaime
 
I see what you're trying to do but it won't work like that.
I'm trying to follow the logic but a bit hard not knowing whats coming into the page and the DB design.

Step_table_name = Step_List.Fields.Item(&quot;Table_Name&quot;).value
What values are derived from this, is one of the tables you're opening at the beginning of the code?

What should be happening between these two lines Step_table_name = Step_List.Fields.Item(&quot;Table_Name&quot;).value

While ((Repeat3__numRows <> 0) AND (NOT Step_List.EOF))


Is that you open the recordset like in my previous comment, and pull the data you want then close it. And then loop round and open the next table.


 
the DB design
Tables
- step_list
list of table names, one table for each of the steps in our process.

- tblIncoming_clean
a step, so in the DB there is a table named tblIncoming_clean to collect information for that step

The idea is to loop through the step_list table assigning
Step_table_name the value that table_name for each record holds.

Step_table_name = Step_list.Fields.item(&quot;table_name&quot;).value


The very first value for &quot;table_name&quot; for the first record in the table Step_list is &quot;tblIncoming_clean&quot;

so the loop is assigning

Step_table_name

the value of tblIncoming_Clean

Step_table_name = (Step_list.Fields.item(&quot;table_name&quot;).value = tblIncoming_Clean)

I am creating a repeat region to display the values for Status of tblIncoming_clean.

tblIncoming_clean.Fields.item(&quot;status&quot;).value

but my idea is to put it in a loop:


While ((Repeat3__numRows <> 0) AND (NOT Step_List.EOF))




Repeat3__index=Repeat2__index+1
Repeat3__numRows=Repeat2__numRows-1
Step_List.MoveNext()
Wend



Where step_table_name is assigned every time with the value on each table_name for each record, and everytime it is assigned it will display the value for status of that table.

so it loops assigning:

Step_table_name = Step_list.Fields.item(&quot;table_name&quot;).value

this would mean each itiration step_table name woudl be something like:

Loop 1
Step_table_name = tblIncoming_Clean
Loop 2
Step_table_name = tbletch_Inspect
Loop 3
Step_table_name = tblMembrane_Grind


and each time it is asked to display the value of field &quot;Status&quot; for each record for the table in that loop, like this:

Loop 1
Step_table_name = tblIncoming_Clean
tblIncoming_Clean.Fields.item(&quot;table_name&quot;).value

Loop 2
Step_table_name = tbletch_Inspect
tbletch_Inspect.Fields.item(&quot;table_name&quot;).value

Loop 3
Step_table_name = tblMembrane_Grind
tblMembrane_Grind.Fields.item(&quot;table_name&quot;).value

etc for 33 more steps.....


For what you are asking:
what is supposed to be happening between those two lines, I just realized that it is supposed to be the other way around:


While ((Repeat3__numRows <> 0) AND (NOT Step_List.EOF))


Step_table_name = Step_list.Fields.item(&quot;table_name&quot;).value




so Step_table_name is assigned every iteration of the loop.



This is being really hard for me to explain that is why I wrote so much, trying to explain in detail. I hope this helps you understand.
Instead of writing out to display the value of a field 34 times, I want to have a loop assing the table name it needs to look into to a variable, then use that to pull the value and display it on the page.


 
Ok I may be totally off here but try this and see if its getting what you want.

<%@LANGUAGE=&quot;VBSCRIPT&quot; CODEPAGE=&quot;1252&quot;%>
<!--#include file=&quot;Connections/spectra_DB_3.asp&quot; -->
<%
Dim Wafer_Reg
Dim Wafer_Reg_numRows

Set Wafer_Reg = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Wafer_Reg.ActiveConnection = MM_spectra_DB_3_STRING
Wafer_Reg.Source = &quot;SELECT * FROM spectra_db_3.tblwafer_reg&quot;
Wafer_Reg.CursorType = 0
Wafer_Reg.CursorLocation = 2
Wafer_Reg.LockType = 1
Wafer_Reg.Open()

Wafer_Reg_numRows = 0

Dim Step_List
Dim Step_List_numRows

Set Step_List = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Step_List.ActiveConnection = MM_spectra_DB_3_STRING
Step_List.Source = &quot;SELECT * FROM spectra_db_3.tblstep_list&quot;
Step_List.CursorType = 0
Step_List.CursorLocation = 2
Step_List.LockType = 1
Step_List.Open()

Step_List_numRows = 0


Dim tempTable

Set tempTable= Server.CreateObject(&quot;ADODB.Recordset&quot;)
tempTable.ActiveConnection = MM_spectra_DB_3_STRING
tempTable.CursorType = 0
tempTable.CursorLocation = 2
tempTable.LockType = 1

Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
Wafer_Reg_numRows = Wafer_Reg_numRows + Repeat1__numRows

Dim Repeat2__numRows
Dim Repeat2__index

Repeat2__numRows = -1
Repeat2__index = 0
Step_List_numRows = Step_List_numRows + Repeat2__numRows

Dim Repeat3__numRows
Dim Repeat3__index

Repeat3__numRows = -1
Repeat3__index = 0
Step_List_numRows = Step_List_numRows + Repeat3__numRows
%>

<html>
<head>
<title>WIP Summary</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>

<body>
<img src=&quot;images/title_bar.gif&quot; width=&quot;500&quot; height=&quot;80&quot;>
<table width=&quot;102%&quot; border=&quot;0&quot; cellpadding=&quot;1&quot; cellspacing=&quot;3&quot;>
<tr>
<td width=&quot;310&quot;> </td>

' Display the list of all the steps in tblStep_list across the top of the page
<% While ((Repeat2__numRows <> 0) AND (NOT Step_List.EOF)) %>
<td width=&quot;630&quot;><font size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;><strong>
<a href=&quot;New_Record/<%=(Step_List.Fields.Item(&quot;New_rec&quot;).Value)%>&quot;>
<%=(Step_List.Fields.Item(&quot;Display_Name&quot;).Value)%>
</a>

</strong></font>
</td>
<%'End loop for Step_List
Repeat2__index=Repeat2__index+1
Repeat2__numRows=Repeat2__numRows-1
Step_List.MoveNext()
Wend
%>
</tr>

<%
While ((Repeat1__numRows <> 0) AND (NOT Wafer_Reg.EOF))
Dim Wafer_Loc
Wafer_Loc = (Wafer_Reg.Fields.Item(&quot;Wafer_ID&quot;).Value)
response.write &quot;<tr>&quot;
response.write &quot;<td width=&quot;&quot;150&quot;&quot;><font size=&quot;&quot;2&quot;&quot; face=&quot;&quot;Verdana, Arial, Helvetica, sans-serif&quot;&quot;><Strong>&quot; & Wafer_Loc & &quot;</Strong></font></td>&quot;
%>
<td width=&quot;630&quot;><font size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>
<%
Step_List.MoveFirst()
Dim Step_table_name

Step_table_name = Step_List.Fields.Item(&quot;Table_Name&quot;).value
tempTable.Source = &quot;SELECT * FROM &quot; & Step_table_name
tempTable.Open()

While ((Repeat3__numRows <> 0) AND (NOT Step_List.EOF)) %>
<a href=&quot;New_Record/<%=(Step_List.Fields.Item(&quot;New_rec&quot;).Value)%>&quot;>

<%=(Step_table_name.fields.item(&quot;status&quot;).value)%> </a>

</font> </td>
<%'End loop for Step_List
Repeat3__index=Repeat2__index+1
Repeat3__numRows=Repeat2__numRows-1
Step_List.MoveNext()
Wend
tempTable.Close

response.write &quot;</tr>&quot;

Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Wafer_Reg.MoveNext()
Wend
%>
</table>
</body>
</html>
<%
Wafer_Reg.Close()
Set Wafer_Reg = Nothing
Step_List.Close()
Set Step_List = Nothing
tempTable.Close()
Set tempTable= Nothing
%>

 
thanks I tried it but I still get the same error.

Microsoft VBScript runtime (0x800A01A8)
Object required: 'tblIncoming_Clean'
/spectra/TMPnlagalbbyc.asp, line 109

the problem is not that it does not open the record or connection to the table. The problem is that I assign the table name to a variable and when I try to use that variable as the table name it sees it as a object on its own.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top