views:

31

answers:

2

This one is a tricky one

I have been looking through the event viewer on our server and can see quite a few people with this error but I can't replicate this myself but it is causing issues for people viewing our website is there anyway I can "initialize" Command Text property?

Thanks

Jamie

UPDATE

So I have this query

datelistquery = "SELECT DISTINCT property_id, ' - Sleeps ' + cast(number_slept as varchar) as combsleeps, number_slept FROM openquery ("+Application("hpbDsrc")+",'SELECT property_id, number_slept FROM web_details WHERE part_full_flag = ''F'' AND location = ''"&Session("TenChosenLocCode")&"'' AND property_id = ''"&Session("passedPropId")&"'' AND pets_yn like ''"&Session("TenPets")&"'' AND number_slept  >= ''"&Session("TenAdults")&"'' AND year_week = ''"&Session("TenHolStDateHP1")&"''  AND on_hold = ''NO'' AND booked = ''NO'' ') ORDER BY number_slept, property_id"    

So should I put at the start sqlCommand.CommandText(datelistquery) = "Select Distinct...."

+1  A: 

You need to make sure that a SQL query is always specified before sending the request to the database:

sqlCommand.CommandText = "SELECT id FROM foo";

The CommandText property must be initialized before executing the query.

Darin Dimitrov
Please see my update above
Jamie Taylor
Is what I did in the update correct?
Jamie Taylor
A: 

I've now added some Try Catch statements in and it seems to be working at the moment

Thanks

Jamie

Jamie Taylor