|
Blastrix
Posting Yak Master
208 Posts |
Posted - 2001-03-28 : 19:50:55
|
| I'm using MSSQL7 and trying to run a stored procedure from an ASP page. Of course I wouldn't be here unless there was a problem, and there is. I run the stored procedure, but it returns saying:Syntax error converting datetime from character string.This is my first shot a big(to me) stored procedure, so I'm a bit lost, but I believe I have traced it to this section of code where the adDateTime >= @adDateTime because if I change >= to just = then it works fine, returning no records. I have checked all variables and made sure that they're sending the appropriate information to the query from the ASP page, and the adDateTime field in the classifieds table is of type dateTime:INSERT INTO #tempList (adId, username, anonName, adDateTime, city, state, country, title, image1, image2, image3, website, adText) SELECT classifieds.adId, classifieds.anonName, classifieds.adDateTime, classifieds.city, classifieds.state, classifieds.country, classifieds.title, classifieds.image1, classifieds.image2, classifieds.image3, classifieds.website, classifieds.adText, users.username FROM classifieds, usersWHERE adType = @adType AND adDateTime >= @adDateTime AND classifieds.userId = users.userIdORDER BY adDateTime DESCI've been busting my rear trying to figure this out for the past three days, and have had absolutely *no* luck.In case I'm completely off here, here's the whole stored procedure:CREATE PROCEDURE [spListAds] ( @adType int, @adDateTime dateTime, @pageNum int, @perPage int )AS-- Don't return number of rows inserted into the temp tableSET NOCOUNT ON-- Create temp tableCREATE TABLE #tempList ( id int IDENTITY, adId int, username varchar(30), anonName varchar(50), adDateTime dateTime, city varchar(50), state varchar(50), country varchar(50), title varchar(50), image1 varchar(100), image2 varchar(100), image3 varchar(100), website varchar(100), adText text ) -- Insert from the classifieds table to the temp tableINSERT INTO #tempList (adId, username, anonName, adDateTime, city, state, country, title, image1, image2, image3, website, adText) SELECT classifieds.adId, classifieds.anonName, classifieds.adDateTime, classifieds.city, classifieds.state, classifieds.country, classifieds.title, classifieds.image1, classifieds.image2, classifieds.image3, classifieds.website, classifieds.adText, users.username FROM classifieds, usersWHERE adType = @adType AND adDateTime >= @adDateTime AND classifieds.userId = users.userIdORDER BY adDateTime DESC-- Figure first and last records that we wantDECLARE @firstRec int, @lastRec intSELECT @firstRec = (@pageNum - 1) * @perPageSELECT @lastRec = (@pageNum * @perPage + 1)-- Return our recordsSELECT *, nextPage = ( SELECT COUNT(*) FROM #tempList tl WHERE tl.id >= @lastRec ), totalAds = ( SELECT COUNT(*) FROM #tempList tl )FROM #tempListWHERE id > @firstRec AND id < @lastRec-- Turn off no count SET NOCOUNT OFF |
|