Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: passing variable into a SQL query with ASP


Message #1 by jay48202@y... on Wed, 2 Oct 2002 23:47:45
Hi,

Kindly help in fixing this problem.

rs.Open "select * from tbLbls where PartType='vPartType'"

I want v20 Engine be substituted in 'vPartType' in the following code, it 
is not doing any good. I couldn't get the records from the database. 
Correct me. Pls help. The following did not work either.

rs.Open "select * from tbLbls where PartType='" & vPartType & "'"

CODE
-----
<FORM name=frmsubmitLabels action=lblValuesSubmit_ac.asp method=post>
<TABLE WIDTH=100% BORDER=1 CELLSPACING=5 CELLPADDING=5>
<% Dim vSeqNum,vPartNum,vPartType

vSeqNum=Request.Form("txtSeqPN")
vPartNum=Request.Form("txtPN")
vPartType=Request.Form("txtPT")'I got the part type as v20 Engine
%>
'Displaying above variable values in a table
	<TR>
		<TD align=center><h4><%Response.Write(vSeqNum)%></h4></TD>
		<TD align=center><h4><%Response.Write(vPartNum)%
></h4></TD>
		<TD align=center><h4><%Response.Write(vPartType)%
</h4></TD>
	</TR>
	
</TABLE>
<%Dim vNumLabels

Set Conn = Server.CreateObject("ADODB.Connection") 
   Conn.Open ("FILEDSN=" + Server.MapPath("Ppk.dsn") + ";")
   
      set rs=Server.CreateObject("ADODB.RecordSet")
   rs.ActiveConnection=Conn

   response.write(vPartType)'v20 Engine displayed

   rs.Open "select * from tblLbls where PartType='vPartType'"

   response.write(vPartType)'v20 Engine displayed
   
   do until rs.EOF
    for each x in rs.Fields
       Response.Write(x.PartType)'PartType is a field in tblLbls
       Response.Write(x.NumLabels)'NumLabels is a field in tblLbls 
    next
    rs.MoveNext
   loop		
		rs.close
		set rs.ActiveConnection=Nothing
                Conn.Close
		set Conn=Nothing
%>

</Form>

Message #2 by "Owen Mortensen" <ojm@a...> on Wed, 2 Oct 2002 15:41:31 -0700
Put an "option explicit" at the top of your code to make sure all
variables are being defined.  The code I sent before will work without
giving an error if all the setup steps are done properly.

Owen

-----Original Message-----
From: jay48202@y... [mailto:jay48202@y...] 
Sent: Wednesday, October 02, 2002 11:48 PM
To: ASP Databases
Subject: [asp_databases] passing variable into a SQL query with ASP


Hi,

Kindly help in fixing this problem.

rs.Open "select * from tbLbls where PartType='vPartType'"

I want v20 Engine be substituted in 'vPartType' in the following code,
it 
is not doing any good. I couldn't get the records from the database. 
Correct me. Pls help. The following did not work either.

rs.Open "select * from tbLbls where PartType='" & vPartType & "'"

CODE
-----
<FORM name=frmsubmitLabels action=lblValuesSubmit_ac.asp method=post>
<TABLE WIDTH=100% BORDER=1 CELLSPACING=5 CELLPADDING=5> <% Dim
vSeqNum,vPartNum,vPartType

vSeqNum=Request.Form("txtSeqPN")
vPartNum=Request.Form("txtPN") vPartType=Request.Form("txtPT")'I got the
part type as v20 Engine %> 'Displaying above variable values in a table
	<TR>
		<TD
align=center><h4><%Response.Write(vSeqNum)%></h4></TD>
		<TD align=center><h4><%Response.Write(vPartNum)%
></h4></TD>
		<TD align=center><h4><%Response.Write(vPartType)%
</h4></TD>
	</TR>
	
</TABLE>
<%Dim vNumLabels

Set Conn = Server.CreateObject("ADODB.Connection") 
   Conn.Open ("FILEDSN=" + Server.MapPath("Ppk.dsn") + ";")
   
      set rs=Server.CreateObject("ADODB.RecordSet")
   rs.ActiveConnection=Conn

   response.write(vPartType)'v20 Engine displayed

   rs.Open "select * from tblLbls where PartType='vPartType'"

   response.write(vPartType)'v20 Engine displayed
   
   do until rs.EOF
    for each x in rs.Fields
       Response.Write(x.PartType)'PartType is a field in tblLbls
       Response.Write(x.NumLabels)'NumLabels is a field in tblLbls 
    next
    rs.MoveNext
   loop		
		rs.close
		set rs.ActiveConnection=Nothing
                Conn.Close
		set Conn=Nothing
%>

</Form>



Message #3 by jay48202@y... on Thu, 3 Oct 2002 00:40:28
Sir,

On keeping Option Explicit, it did not work. The following error is 
produced :-

Error Type:
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method: 'PartType'
---- line 44

I am wondering, it(vPartType) is able to print out the value using 
response.write(kindly notice the position of those statement's) but 
unable to get it in SQL statement. All other constraints are absolutely 
correct.

Please help me out.

Thanks,
Sujay









> Put an "option explicit" at the top of your code to make sure all
variables are being defined.  The code I sent before will work without
giving an error if all the setup steps are done properly.

Owen

-----Original Message-----
From: jay48202@y... [mailto:jay48202@y...] 
Sent: Wednesday, October 02, 2002 11:48 PM
To: ASP Databases
Subject: [asp_databases] passing variable into a SQL query with ASP


Hi,

Kindly help in fixing this problem.

rs.Open "select * from tbLbls where PartType='vPartType'"

I want v20 Engine be substituted in 'vPartType' in the following code,
it 
is not doing any good. I couldn't get the records from the database. 
Correct me. Pls help. The following did not work either.

rs.Open "select * from tbLbls where PartType='" & vPartType & "'"

CODE
-----
<FORM name=frmsubmitLabels action=lblValuesSubmit_ac.asp method=post>
<TABLE WIDTH=100% BORDER=1 CELLSPACING=5 CELLPADDING=5> <% Dim
vSeqNum,vPartNum,vPartType

vSeqNum=Request.Form("txtSeqPN")
vPartNum=Request.Form("txtPN") vPartType=Request.Form("txtPT")'I got the
part type as v20 Engine %> 'Displaying above variable values in a table
	<TR>
		<TD
align=center><h4><%Response.Write(vSeqNum)%></h4></TD>
		<TD align=center><h4><%Response.Write(vPartNum)%
></h4></TD>
		<TD align=center><h4><%Response.Write(vPartType)%
</h4></TD>
	</TR>
	
</TABLE>
<%Dim vNumLabels

Set Conn = Server.CreateObject("ADODB.Connection") 
   Conn.Open ("FILEDSN=" + Server.MapPath("Ppk.dsn") + ";")
   
      set rs=Server.CreateObject("ADODB.RecordSet")
   rs.ActiveConnection=Conn

   response.write(vPartType)'v20 Engine displayed

   rs.Open "select * from tblLbls where PartType='vPartType'"

   response.write(vPartType)'v20 Engine displayed
   
   do until rs.EOF
    for each x in rs.Fields
       Response.Write(x.PartType)'PartType is a field in tblLbls
       Response.Write(x.NumLabels)'NumLabels is a field in tblLbls 
    next
    rs.MoveNext
   loop		
		rs.close
		set rs.ActiveConnection=Nothing
                Conn.Close
		set Conn=Nothing
%>

</Form>



Message #4 by "Owen Mortensen" <ojm@a...> on Wed, 2 Oct 2002 16:45:32 -0700
OK.  Try this:

strSQL = "select * from tbLbls where PartType='vPartType'"
Response.write strSQL & "<br>"
rs.Open strSQL

Owen

-----Original Message-----
From: jay48202@y... [mailto:jay48202@y...] 
Sent: Thursday, October 03, 2002 12:40 AM
To: ASP Databases
Subject: [asp_databases] RE: passing variable into a SQL query with ASP


Sir,

On keeping Option Explicit, it did not work. The following error is 
produced :-

Error Type:
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method: 'PartType'
---- line 44

I am wondering, it(vPartType) is able to print out the value using 
response.write(kindly notice the position of those statement's) but 
unable to get it in SQL statement. All other constraints are absolutely 
correct.

Please help me out.

Thanks,
Sujay









> Put an "option explicit" at the top of your code to make sure all
variables are being defined.  The code I sent before will work without
giving an error if all the setup steps are done properly.

Owen

-----Original Message-----
From: jay48202@y... [mailto:jay48202@y...] 
Sent: Wednesday, October 02, 2002 11:48 PM
To: ASP Databases
Subject: [asp_databases] passing variable into a SQL query with ASP


Hi,

Kindly help in fixing this problem.

rs.Open "select * from tbLbls where PartType='vPartType'"

I want v20 Engine be substituted in 'vPartType' in the following code,
it 
is not doing any good. I couldn't get the records from the database. 
Correct me. Pls help. The following did not work either.

rs.Open "select * from tbLbls where PartType='" & vPartType & "'"

CODE
-----
<FORM name=frmsubmitLabels action=lblValuesSubmit_ac.asp method=post>
<TABLE WIDTH=100% BORDER=1 CELLSPACING=5 CELLPADDING=5> <% Dim
vSeqNum,vPartNum,vPartType

vSeqNum=Request.Form("txtSeqPN")
vPartNum=Request.Form("txtPN") vPartType=Request.Form("txtPT")'I got the
part type as v20 Engine %> 'Displaying above variable values in a table
	<TR>
		<TD
align=center><h4><%Response.Write(vSeqNum)%></h4></TD>
		<TD align=center><h4><%Response.Write(vPartNum)%
></h4></TD>
		<TD align=center><h4><%Response.Write(vPartType)%
</h4></TD>
	</TR>
	
</TABLE>
<%Dim vNumLabels

Set Conn = Server.CreateObject("ADODB.Connection") 
   Conn.Open ("FILEDSN=" + Server.MapPath("Ppk.dsn") + ";")
   
      set rs=Server.CreateObject("ADODB.RecordSet")
   rs.ActiveConnection=Conn

   response.write(vPartType)'v20 Engine displayed

   rs.Open "select * from tblLbls where PartType='vPartType'"

   response.write(vPartType)'v20 Engine displayed
   
   do until rs.EOF
    for each x in rs.Fields
       Response.Write(x.PartType)'PartType is a field in tblLbls
       Response.Write(x.NumLabels)'NumLabels is a field in tblLbls 
    next
    rs.MoveNext
   loop		
		rs.close
		set rs.ActiveConnection=Nothing
                Conn.Close
		set Conn=Nothing
%>

</Form>





Message #5 by jay48202@y... on Thu, 3 Oct 2002 01:41:47
Hi,

This is the output I am seeing

21             14.52.001.36.01             ColdEnd 

 v20Engine select * from tbLbls where PartType='vPartType'
v20Engine.

I haven't seen anyoutput for these two statements
Response.Write(x.PartType)'PartType is a field in tblLbls
       Response.Write(x.NumLabels)'NumLabels is a field in tblLbls 

Thanks,
Jay





> OK.  Try this:

strSQL = "select * from tbLbls where PartType='vPartType'"
Response.write strSQL & "<br>"
rs.Open strSQL

Owen

-----Original Message-----
From: jay48202@y... [mailto:jay48202@y...] 
Sent: Thursday, October 03, 2002 12:40 AM
To: ASP Databases
Subject: [asp_databases] RE: passing variable into a SQL query with ASP


Sir,

On keeping Option Explicit, it did not work. The following error is 
produced :-

Error Type:
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method: 'PartType'
---- line 44

I am wondering, it(vPartType) is able to print out the value using 
response.write(kindly notice the position of those statement's) but 
unable to get it in SQL statement. All other constraints are absolutely 
correct.

Please help me out.

Thanks,
Sujay









> Put an "option explicit" at the top of your code to make sure all
variables are being defined.  The code I sent before will work without
giving an error if all the setup steps are done properly.

Owen

-----Original Message-----
From: jay48202@y... [mailto:jay48202@y...] 
Sent: Wednesday, October 02, 2002 11:48 PM
To: ASP Databases
Subject: [asp_databases] passing variable into a SQL query with ASP


Hi,

Kindly help in fixing this problem.

rs.Open "select * from tbLbls where PartType='vPartType'"

I want v20 Engine be substituted in 'vPartType' in the following code,
it 
is not doing any good. I couldn't get the records from the database. 
Correct me. Pls help. The following did not work either.

rs.Open "select * from tbLbls where PartType='" & vPartType & "'"

CODE
-----
<FORM name=frmsubmitLabels action=lblValuesSubmit_ac.asp method=post>
<TABLE WIDTH=100% BORDER=1 CELLSPACING=5 CELLPADDING=5> <% Dim
vSeqNum,vPartNum,vPartType

vSeqNum=Request.Form("txtSeqPN")
vPartNum=Request.Form("txtPN") vPartType=Request.Form("txtPT")'I got the
part type as v20 Engine %> 'Displaying above variable values in a table
	<TR>
		<TD
align=center><h4><%Response.Write(vSeqNum)%></h4></TD>
		<TD align=center><h4><%Response.Write(vPartNum)%
></h4></TD>
		<TD align=center><h4><%Response.Write(vPartType)%
</h4></TD>
	</TR>
	
</TABLE>
<%Dim vNumLabels

Set Conn = Server.CreateObject("ADODB.Connection") 
   Conn.Open ("FILEDSN=" + Server.MapPath("Ppk.dsn") + ";")
   
      set rs=Server.CreateObject("ADODB.RecordSet")
   rs.ActiveConnection=Conn

   response.write(vPartType)'v20 Engine displayed

   rs.Open "select * from tblLbls where PartType='vPartType'"

   response.write(vPartType)'v20 Engine displayed
   
   do until rs.EOF
    for each x in rs.Fields
       Response.Write(x.PartType)'PartType is a field in tblLbls
       Response.Write(x.NumLabels)'NumLabels is a field in tblLbls 
    next
    rs.MoveNext
   loop		
		rs.close
		set rs.ActiveConnection=Nothing
                Conn.Close
		set Conn=Nothing
%>

</Form>





Message #6 by "Owen Mortensen" <ojm@a...> on Wed, 2 Oct 2002 17:54:26 -0700
Hmmm.  Something's wrong.  The output should look like this:
21
14.52.001.36.01
ColdEnd
v20Engine
Select * from tbLbls where PartType='v20Engine'.

Cut and paste your code as it now exists again.

Owen

-----Original Message-----
From: jay48202@y... [mailto:jay48202@y...] 
Sent: Thursday, October 03, 2002 1:42 AM
To: ASP Databases
Subject: [asp_databases] RE: passing variable into a SQL query with ASP


Hi,

This is the output I am seeing

21             14.52.001.36.01             ColdEnd 

 v20Engine select * from tbLbls where PartType='vPartType' v20Engine.

I haven't seen anyoutput for these two statements
Response.Write(x.PartType)'PartType is a field in tblLbls
       Response.Write(x.NumLabels)'NumLabels is a field in tblLbls 

Thanks,
Jay





> OK.  Try this:

strSQL = "select * from tbLbls where PartType='vPartType'"
Response.write strSQL & "<br>" rs.Open strSQL

Owen

-----Original Message-----
From: jay48202@y... [mailto:jay48202@y...] 
Sent: Thursday, October 03, 2002 12:40 AM
To: ASP Databases
Subject: [asp_databases] RE: passing variable into a SQL query with ASP


Sir,

On keeping Option Explicit, it did not work. The following error is 
produced :-

Error Type:
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method: 'PartType'
---- line 44

I am wondering, it(vPartType) is able to print out the value using 
response.write(kindly notice the position of those statement's) but 
unable to get it in SQL statement. All other constraints are absolutely 
correct.

Please help me out.

Thanks,
Sujay









> Put an "option explicit" at the top of your code to make sure all
variables are being defined.  The code I sent before will work without
giving an error if all the setup steps are done properly.

Owen

-----Original Message-----
From: jay48202@y... [mailto:jay48202@y...] 
Sent: Wednesday, October 02, 2002 11:48 PM
To: ASP Databases
Subject: [asp_databases] passing variable into a SQL query with ASP


Hi,

Kindly help in fixing this problem.

rs.Open "select * from tbLbls where PartType='vPartType'"

I want v20 Engine be substituted in 'vPartType' in the following code,
it 
is not doing any good. I couldn't get the records from the database. 
Correct me. Pls help. The following did not work either.

rs.Open "select * from tbLbls where PartType='" & vPartType & "'"

CODE
-----
<FORM name=frmsubmitLabels action=lblValuesSubmit_ac.asp method=post>
<TABLE WIDTH=100% BORDER=1 CELLSPACING=5 CELLPADDING=5> <% Dim
vSeqNum,vPartNum,vPartType

vSeqNum=Request.Form("txtSeqPN")
vPartNum=Request.Form("txtPN") vPartType=Request.Form("txtPT")'I got the
part type as v20 Engine %> 'Displaying above variable values in a table
	<TR>
		<TD
align=center><h4><%Response.Write(vSeqNum)%></h4></TD>
		<TD align=center><h4><%Response.Write(vPartNum)%
></h4></TD>
		<TD align=center><h4><%Response.Write(vPartType)%
</h4></TD>
	</TR>
	
</TABLE>
<%Dim vNumLabels

Set Conn = Server.CreateObject("ADODB.Connection") 
   Conn.Open ("FILEDSN=" + Server.MapPath("Ppk.dsn") + ";")
   
      set rs=Server.CreateObject("ADODB.RecordSet")
   rs.ActiveConnection=Conn

   response.write(vPartType)'v20 Engine displayed

   rs.Open "select * from tblLbls where PartType='vPartType'"

   response.write(vPartType)'v20 Engine displayed
   
   do until rs.EOF
    for each x in rs.Fields
       Response.Write(x.PartType)'PartType is a field in tblLbls
       Response.Write(x.NumLabels)'NumLabels is a field in tblLbls 
    next
    rs.MoveNext
   loop		
		rs.close
		set rs.ActiveConnection=Nothing
                Conn.Close
		set Conn=Nothing
%>

</Form>







Message #7 by jay48202@y... on Thu, 3 Oct 2002 02:25:15
hi,

I really appreciate for your help.

Thanks again,
Jay

-----------------------------------------------------------------------
<HTML>
<HEAD>

<TITLE></TITLE>

</HEAD>
<BODY bgcolor="silver">

<FORM name=frmsubmitLabels action=lblValuesSubmit_ac.asp method=post>
<TABLE WIDTH=100% BORDER=1 CELLSPACING=5 CELLPADDING=5>
<%
Option Explicit
Dim vSeqNum,vPartNum,vPartType,vNumLabels
   Set Conn = Server.CreateObject("ADODB.Connection") 
   Conn.Open ("FILEDSN=" + Server.MapPath("Ppk.dsn") + ";")
   
   set rs=Server.CreateObject("ADODB.RecordSet")
   rs.ActiveConnection=Conn
vSeqNum=Request.Form("txtSeqPN")
vPartNum=Request.Form("txtPN")
vPartType=Request.Form("txtPT")

%>
<TR>
	<TD align=center><h4><%Response.Write(vSeqNum)%></h4></TD>
	<TD align=center><h4><%Response.Write(vPartNum)%></h4></TD>
	<TD align=center><h4><%Response.Write(vPartType)%></h4></TD>
</TR>
	
</TABLE>
<%
   
     
   response.write(vPartType)'I got the value here
   
   strSQL = "select * from tbLbls where PartType='vPartType'"
   
   Response.write strSQL & "<br>"

   rs.Open strSQL
   
   'rs.Open "select * from tbLbls where PartType='vPartType'"
   
   response.write(vPartType)'I got the value again
   
	
	do until rs.EOF
    for each x in rs.Fields
       Response.Write(x.PartType)
       Response.Write(x.NumLabels & "<br />") 
    next
    Response.Write("<br />")
    rs.MoveNext
	loop
		rs.close
		set rs.ActiveConnection=Nothing
		Conn.Close
		set Conn=Nothing
	%>

</Form>


</BODY>
</HTML>
----------------------------------------------------------------------












> Hmmm.  Something's wrong.  The output should look like this:
21
14.52.001.36.01
ColdEnd
v20Engine
Select * from tbLbls where PartType='v20Engine'.

Cut and paste your code as it now exists again.

Owen

-----Original Message-----
From: jay48202@y... [mailto:jay48202@y...] 
Sent: Thursday, October 03, 2002 1:42 AM
To: ASP Databases
Subject: [asp_databases] RE: passing variable into a SQL query with ASP


Hi,

This is the output I am seeing

21             14.52.001.36.01             ColdEnd 

 v20Engine select * from tbLbls where PartType='vPartType' v20Engine.

I haven't seen anyoutput for these two statements
Response.Write(x.PartType)'PartType is a field in tblLbls
       Response.Write(x.NumLabels)'NumLabels is a field in tblLbls 

Thanks,
Jay





> OK.  Try this:

strSQL = "select * from tbLbls where PartType='vPartType'"
Response.write strSQL & "<br>" rs.Open strSQL

Owen

-----Original Message-----
From: jay48202@y... [mailto:jay48202@y...] 
Sent: Thursday, October 03, 2002 12:40 AM
To: ASP Databases
Subject: [asp_databases] RE: passing variable into a SQL query with ASP


Sir,

On keeping Option Explicit, it did not work. The following error is 
produced :-

Error Type:
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method: 'PartType'
---- line 44

I am wondering, it(vPartType) is able to print out the value using 
response.write(kindly notice the position of those statement's) but 
unable to get it in SQL statement. All other constraints are absolutely 
correct.

Please help me out.

Thanks,
Sujay









> Put an "option explicit" at the top of your code to make sure all
variables are being defined.  The code I sent before will work without
giving an error if all the setup steps are done properly.

Owen

-----Original Message-----
From: jay48202@y... [mailto:jay48202@y...] 
Sent: Wednesday, October 02, 2002 11:48 PM
To: ASP Databases
Subject: [asp_databases] passing variable into a SQL query with ASP


Hi,

Kindly help in fixing this problem.

rs.Open "select * from tbLbls where PartType='vPartType'"

I want v20 Engine be substituted in 'vPartType' in the following code,
it 
is not doing any good. I couldn't get the records from the database. 
Correct me. Pls help. The following did not work either.

rs.Open "select * from tbLbls where PartType='" & vPartType & "'"

CODE
-----
<FORM name=frmsubmitLabels action=lblValuesSubmit_ac.asp method=post>
<TABLE WIDTH=100% BORDER=1 CELLSPACING=5 CELLPADDING=5> <% Dim
vSeqNum,vPartNum,vPartType

vSeqNum=Request.Form("txtSeqPN")
vPartNum=Request.Form("txtPN") vPartType=Request.Form("txtPT")'I got the
part type as v20 Engine %> 'Displaying above variable values in a table
	<TR>
		<TD
align=center><h4><%Response.Write(vSeqNum)%></h4></TD>
		<TD align=center><h4><%Response.Write(vPartNum)%
></h4></TD>
		<TD align=center><h4><%Response.Write(vPartType)%
</h4></TD>
	</TR>
	
</TABLE>
<%Dim vNumLabels

Set Conn = Server.CreateObject("ADODB.Connection") 
   Conn.Open ("FILEDSN=" + Server.MapPath("Ppk.dsn") + ";")
   
      set rs=Server.CreateObject("ADODB.RecordSet")
   rs.ActiveConnection=Conn

   response.write(vPartType)'v20 Engine displayed

   rs.Open "select * from tblLbls where PartType='vPartType'"

   response.write(vPartType)'v20 Engine displayed
   
   do until rs.EOF
    for each x in rs.Fields
       Response.Write(x.PartType)'PartType is a field in tblLbls
       Response.Write(x.NumLabels)'NumLabels is a field in tblLbls 
    next
    rs.MoveNext
   loop		
		rs.close
		set rs.ActiveConnection=Nothing
                Conn.Close
		set Conn=Nothing
%>

</Form>







Message #8 by "Owen Mortensen" <ojm@a...> on Thu, 3 Oct 2002 08:02:08 -0700
OK, you need to change a line again. Note the difference between the
following two lines:
   strSQL = "select * from tbLbls where PartType='vPartType'"
   strSQL = "select * from tbLbls where PartType='" & vPartType & "'"
The second one is correct.

Owen

-----Original Message-----
From: jay48202@y... [mailto:jay48202@y...] 
Sent: Thursday, October 03, 2002 2:25 AM
To: ASP Databases
Subject: [asp_databases] RE: passing variable into a SQL query with ASP


hi,

I really appreciate for your help.

Thanks again,
Jay

-----------------------------------------------------------------------
<HTML>
<HEAD>

<TITLE></TITLE>

</HEAD>
<BODY bgcolor="silver">

<FORM name=frmsubmitLabels action=lblValuesSubmit_ac.asp method=post>
<TABLE WIDTH=100% BORDER=1 CELLSPACING=5 CELLPADDING=5> <% Option
Explicit Dim vSeqNum,vPartNum,vPartType,vNumLabels
   Set Conn = Server.CreateObject("ADODB.Connection") 
   Conn.Open ("FILEDSN=" + Server.MapPath("Ppk.dsn") + ";")
   
   set rs=Server.CreateObject("ADODB.RecordSet")
   rs.ActiveConnection=Conn
vSeqNum=Request.Form("txtSeqPN")
vPartNum=Request.Form("txtPN")
vPartType=Request.Form("txtPT")

%>
<TR>
	<TD align=center><h4><%Response.Write(vSeqNum)%></h4></TD>
	<TD align=center><h4><%Response.Write(vPartNum)%></h4></TD>
	<TD align=center><h4><%Response.Write(vPartType)%></h4></TD>
</TR>
	
</TABLE>
<%
   
     
   response.write(vPartType)'I got the value here
   
   strSQL = "select * from tbLbls where PartType='vPartType'"
   
   Response.write strSQL & "<br>"

   rs.Open strSQL
   
   'rs.Open "select * from tbLbls where PartType='vPartType'"
   
   response.write(vPartType)'I got the value again
   
	
	do until rs.EOF
    for each x in rs.Fields
       Response.Write(x.PartType)
       Response.Write(x.NumLabels & "<br />") 
    next
    Response.Write("<br />")
    rs.MoveNext
	loop
		rs.close
		set rs.ActiveConnection=Nothing
		Conn.Close
		set Conn=Nothing
	%>

</Form>


</BODY>
</HTML>
----------------------------------------------------------------------












> Hmmm.  Something's wrong.  The output should look like this:
21
14.52.001.36.01
ColdEnd
v20Engine
Select * from tbLbls where PartType='v20Engine'.

Cut and paste your code as it now exists again.

Owen

-----Original Message-----
From: jay48202@y... [mailto:jay48202@y...] 
Sent: Thursday, October 03, 2002 1:42 AM
To: ASP Databases
Subject: [asp_databases] RE: passing variable into a SQL query with ASP


Hi,

This is the output I am seeing

21             14.52.001.36.01             ColdEnd 

 v20Engine select * from tbLbls where PartType='vPartType' v20Engine.

I haven't seen anyoutput for these two statements
Response.Write(x.PartType)'PartType is a field in tblLbls
       Response.Write(x.NumLabels)'NumLabels is a field in tblLbls 

Thanks,
Jay





> OK.  Try this:

strSQL = "select * from tbLbls where PartType='vPartType'"
Response.write strSQL & "<br>" rs.Open strSQL

Owen

-----Original Message-----
From: jay48202@y... [mailto:jay48202@y...] 
Sent: Thursday, October 03, 2002 12:40 AM
To: ASP Databases
Subject: [asp_databases] RE: passing variable into a SQL query with ASP


Sir,

On keeping Option Explicit, it did not work. The following error is 
produced :-

Error Type:
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method: 'PartType'
---- line 44

I am wondering, it(vPartType) is able to print out the value using 
response.write(kindly notice the position of those statement's) but 
unable to get it in SQL statement. All other constraints are absolutely 
correct.

Please help me out.

Thanks,
Sujay









> Put an "option explicit" at the top of your code to make sure all
variables are being defined.  The code I sent before will work without
giving an error if all the setup steps are done properly.

Owen

-----Original Message-----
From: jay48202@y... [mailto:jay48202@y...] 
Sent: Wednesday, October 02, 2002 11:48 PM
To: ASP Databases
Subject: [asp_databases] passing variable into a SQL query with ASP


Hi,

Kindly help in fixing this problem.

rs.Open "select * from tbLbls where PartType='vPartType'"

I want v20 Engine be substituted in 'vPartType' in the following code,
it 
is not doing any good. I couldn't get the records from the database. 
Correct me. Pls help. The following did not work either.

rs.Open "select * from tbLbls where PartType='" & vPartType & "'"

CODE
-----
<FORM name=frmsubmitLabels action=lblValuesSubmit_ac.asp method=post>
<TABLE WIDTH=100% BORDER=1 CELLSPACING=5 CELLPADDING=5> <% Dim
vSeqNum,vPartNum,vPartType

vSeqNum=Request.Form("txtSeqPN")
vPartNum=Request.Form("txtPN") vPartType=Request.Form("txtPT")'I got the
part type as v20 Engine %> 'Displaying above variable values in a table
	<TR>
		<TD
align=center><h4><%Response.Write(vSeqNum)%></h4></TD>
		<TD align=center><h4><%Response.Write(vPartNum)%
></h4></TD>
		<TD align=center><h4><%Response.Write(vPartType)%
</h4></TD>
	</TR>
	
</TABLE>
<%Dim vNumLabels

Set Conn = Server.CreateObject("ADODB.Connection") 
   Conn.Open ("FILEDSN=" + Server.MapPath("Ppk.dsn") + ";")
   
      set rs=Server.CreateObject("ADODB.RecordSet")
   rs.ActiveConnection=Conn

   response.write(vPartType)'v20 Engine displayed

   rs.Open "select * from tblLbls where PartType='vPartType'"

   response.write(vPartType)'v20 Engine displayed
   
   do until rs.EOF
    for each x in rs.Fields
       Response.Write(x.PartType)'PartType is a field in tblLbls
       Response.Write(x.NumLabels)'NumLabels is a field in tblLbls 
    next
    rs.MoveNext
   loop		
		rs.close
		set rs.ActiveConnection=Nothing
                Conn.Close
		set Conn=Nothing
%>

</Form>










  Return to Index