p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

asptoday_discuss thread: Error in using recordset


Message #1 by "Tan Chye Ting" <chyeting18@h...> on Thu, 17 Jan 2002 14:23:19
can anyone tell me what is wrong with this sql statement.



if Session("CNetProfit") = "Yes" then

dim rsChart

set rsChart = server.CreateObject("ADODB.Recordset")

strSQL = "Select * FROM InvestmentData WHERE ShareID=" & Session("Share")

& " AND Aspect="1";"

rsChart.Open strSQL,objConn,adOpenForwardOnly,adLockOptimistic

call DrawChart(rsChart("1997"),rsChart("1998"),rsChart("1999"),rsChart

("2000"),rsChart("2001"))

end if





what i'm trying to do is select all(*) fields from InvestmentData table 

which has the same ShareID as Session("Share") and has Aspect=1.how should 

i construct the sql statement?and is the rsChart.Open correct?becoz i keep 

getting and error message when i try to run this code..Thank you
Message #2 by "Greg Jennings" <greg.jennings@t...> on Thu, 17 Jan 2002 14:40:47
Assuming ShareID is a numeric field and Aspect is a numeric field:

strSQL = "select * from investmentdata where shareid=" &

   session("Share") & " and aspect=1"



Assuming ShareID is a numeric field and Aspect is a character field:

strSQL = "select * from investmentdata where shareid=" &

   session("Share") & " and aspect='1'"





> can anyone tell me what is wrong with this sql statement.

> 

> if Session("CNetProfit") = "Yes" then

> dim rsChart

> set rsChart = server.CreateObject("ADODB.Recordset")

> strSQL = "Select * FROM InvestmentData WHERE ShareID=" & Session("Share")

> & " AND Aspect="1";"

> rsChart.Open strSQL,objConn,adOpenForwardOnly,adLockOptimistic

> call DrawChart(rsChart("1997"),rsChart("1998"),rsChart("1999"),rsChart

> ("2000"),rsChart("2001"))

> end if

> 

> 

> what i'm trying to do is select all(*) fields from InvestmentData table 

> which has the same ShareID as Session("Share") and has Aspect=1.how 

should 

> i construct the sql statement?and is the rsChart.Open correct?becoz i 

keep 

> getting and error message when i try to run this code..Thank you
Message #3 by "Tan Chye Ting" <chyeting18@h...> on Fri, 18 Jan 2002 01:23:33
hi thanx for your answer, but i still get this error

Microsoft JET Database Engine error '80040e07' 



Data type mismatch in criteria expression. 



/ASP/Shares/Conglomerates/Sime/simedarbyA.asp, line 133 

what if my ShareID is a character field.will it cause this error.Or is it 

something wrong with my rsChart.Open line of coding..could you please 

check for me?thank you



> Assuming ShareID is a numeric field and Aspect is a numeric field:

> strSQL = "select * from investmentdata where shareid=" &

>    session("Share") & " and aspect=1"

> 

> Assuming ShareID is a numeric field and Aspect is a character field:

> strSQL = "select * from investmentdata where shareid=" &

>    session("Share") & " and aspect='1'"

> 

> 

> > can anyone tell me what is wrong with this sql statement.

> > 

> > if Session("CNetProfit") = "Yes" then

> > dim rsChart

> > set rsChart = server.CreateObject("ADODB.Recordset")

> > strSQL = "Select * FROM InvestmentData WHERE ShareID=" & Session

("Share")

> > & " AND Aspect="1";"

> > rsChart.Open strSQL,objConn,adOpenForwardOnly,adLockOptimistic

> > call DrawChart(rsChart("1997"),rsChart("1998"),rsChart("1999"),rsChart

> > ("2000"),rsChart("2001"))

> > end if

> > 

> > 

> > what i'm trying to do is select all(*) fields from InvestmentData 

table 

> > which has the same ShareID as Session("Share") and has Aspect=1.how 

> should 

> > i construct the sql statement?and is the rsChart.Open correct?becoz i 

> keep 

> > getting and error message when i try to run this code..Thank you
Message #4 by "Greg Jennings" <greg.jennings@t...> on Fri, 18 Jan 2002 13:20:01
Yes, if ShareID is a character field, it would be a problem.



Assuming ShareID is a character field and Aspect is a numeric field:

strSQL = "select * from investmentdata where shareid='" &

   session("Share") & "' and aspect=1"



Assuming ShareID is a character field and Aspect is a character field:

strSQL = "select * from investmentdata where shareid='" &

   session("Share") & "' and aspect='1'"



If this still does not fix the problem, find line 133 in your ASP file and 

paste it here.



Greg



> hi thanx for your answer, but i still get this error

> Microsoft JET Database Engine error '80040e07' 

> 

> Data type mismatch in criteria expression. 

> 

> /ASP/Shares/Conglomerates/Sime/simedarbyA.asp, line 133 

> what if my ShareID is a character field.will it cause this error.Or is 

it 

> something wrong with my rsChart.Open line of coding..could you please 

> check for me?thank you

> 

> > Assuming ShareID is a numeric field and Aspect is a numeric field:

> > strSQL = "select * from investmentdata where shareid=" &

> >    session("Share") & " and aspect=1"

> > 

> > Assuming ShareID is a numeric field and Aspect is a character field:

> > strSQL = "select * from investmentdata where shareid=" &

> >    session("Share") & " and aspect='1'"

> > 

> > 

> > > can anyone tell me what is wrong with this sql statement.

> > > 

> > > if Session("CNetProfit") = "Yes" then

> > > dim rsChart

> > > set rsChart = server.CreateObject("ADODB.Recordset")

> > > strSQL = "Select * FROM InvestmentData WHERE ShareID=" & Session

> ("Share")

> > > & " AND Aspect="1";"

> > > rsChart.Open strSQL,objConn,adOpenForwardOnly,adLockOptimistic

> > > call DrawChart(rsChart("1997"),rsChart("1998"),rsChart

("1999"),rsChart

> > > ("2000"),rsChart("2001"))

> > > end if

> > > 

> > > 

> > > what i'm trying to do is select all(*) fields from InvestmentData 

> table 

> > > which has the same ShareID as Session("Share") and has Aspect=1.how 

> > should 

> > > i construct the sql statement?and is the rsChart.Open correct?becoz 

i 

> > keep 

> > > getting and error message when i try to run this code..Thank you

  Return to Index