tags:

views:

30

answers:

2

I keep getting the error ExecuteReader: CommandText property has not been initialized and i'm not sure why it points to this line in my code

   dd1.DataSource = LogData.StermQ2(datelistquery).Tables(0).DefaultView
    dd1.DataBind()
    dd1.Items.Insert(0, new listitem("Any location", "%"))

The top line is the one with the error

Any help would be much appreciated

Thanks

Jamie

A: 

I suspect it has something to do with your data source:

LogData.StermQ2(datelistquery)

Typically, when I'm working with some a SQLDataSource, I have to initialize is like so:

mydatasource.SelectCommand = "select * from mytable"
dd1.DataBind()

SelectCommand is the CommandText is the query that you're passing in. If the property has not been initialized, perhaps you havn't created the command yet? Or perhaps the datasource itself has not been initialized yet.

Anton
A: 

The weird thing with it is that it only happened occasionally and if i emptied my cache it would work fine.

So I just disable caching on that page and it seems to be working (at the moment)

Also added in some Try Catch statements and seems to be ok

Thanks for the help though

Jamie

Jamie Taylor