I have a problem when i am trying to query table that have space in the name. For eg i have table "part master". when i use a asp page to query this table inorder to use quotes around that table i have written the code as shown below. I am not happy with is rude method of adding code around the table. This code does work but would like to have better implementation. Any suggestion will be greatly appreciated.
the script that have written is as shown below
<html>
<head>
<meta NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<body>
<%
Dim objConn
dim var
'Creating a variable to store "
strDQuote = chr(34)
Set objConn = server.CreateObject("ADODB.Connection"
'Use the next line for and DSN connection
objConn.ConnectionString = "DSN=test"
objConn.Open
' using the strDQuote to be added around the table.
' I have tried these options but they all give errors
' mysql="select * from part master"
' mysql="select * from" & "part master"
' The option give below works fine but will be very hard to use when i dealing with very long queries. If there is better please do send your suggestions.
mysql="select * from " & strDQuote & "part master" & strDQuote
set rstemp=objconn.execute(mysql)
if rstemp.eof then
response.write "no records found"
response.write mysql
objconn.close
set objconn=nothing
response.end
end if
do while not rstemp.eof
response.write "First field "& rstemp("PRTNUM_01"
& "<br>"
response.write "second field "& rstemp("type_01"
rstemp.MoveNext
Loop
rstemp.close
set rstemp=nothing
objConn.Close
set objConn=nothing
%>
</body>
</html>
If any body has worked with table name with spaces(i.e part master and not partMaster) and used them in asp pages to query the tables please do let me know.
Thank You in Advance,
the script that have written is as shown below
<html>
<head>
<meta NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<body>
<%
Dim objConn
dim var
'Creating a variable to store "
strDQuote = chr(34)
Set objConn = server.CreateObject("ADODB.Connection"
'Use the next line for and DSN connection
objConn.ConnectionString = "DSN=test"
objConn.Open
' using the strDQuote to be added around the table.
' I have tried these options but they all give errors
' mysql="select * from part master"
' mysql="select * from" & "part master"
' The option give below works fine but will be very hard to use when i dealing with very long queries. If there is better please do send your suggestions.
mysql="select * from " & strDQuote & "part master" & strDQuote
set rstemp=objconn.execute(mysql)
if rstemp.eof then
response.write "no records found"
response.write mysql
objconn.close
set objconn=nothing
response.end
end if
do while not rstemp.eof
response.write "First field "& rstemp("PRTNUM_01"
response.write "second field "& rstemp("type_01"
rstemp.MoveNext
Loop
rstemp.close
set rstemp=nothing
objConn.Close
set objConn=nothing
%>
</body>
</html>
If any body has worked with table name with spaces(i.e part master and not partMaster) and used them in asp pages to query the tables please do let me know.
Thank You in Advance,