laled
9/4/2002 12:50:00 AM
The adapter in general closes the datareader. The fact
that it is left open after a Fill indicates that some
kind of error occured during the Fill, and the operation
was aborted prematurely.
You can get more info on what kind of error occured by
listening to FillError events.
laled
This posting is provided "AS IS" with no warranties, and
confers no rights.
>-----Original Message-----
>actually i can't. the adapter should have done that.
it should have opened
>the reader - populated the dataset, and then closed the
reader. i don't
>think the odbc adapter is closing the reader which is
why this bug occurs.
>
>cheers
>
>jason
>
>"laled" <laled@nospam.microsoft.com> wrote in message
>news:662d01c2495b$c2708200$9ee62ecf@tkmsftngxa05...
>> Yes, the same command can be re-used again. But you
have
>> to close the dara reader obtained from the first
>> execution first.
>>
>> This posting is provided "AS IS" with no warranties,
and
>> confers no rights.
>>
>> laled
>> >-----Original Message-----
>> >Hi All
>> >
>> >I set up a OdbcCommand as my SelectCommand in an
Adapter
>> and have one
>> >parameter like so - "select * from mytable where
myfield
>> = ?"
>> >
>> >I add the paramter to the parameters collection of the
>> OdbcCommand object.
>> >
>> >I call a function described below two times. The first
>> time i call it i set
>> >the value of the parameter i added to the paramters
>> collection of the above
>> >command object; before the Adapter in which it is used
>> as a SelectCommand
>> >then gets a fill call on it. This is fine the first
>> time around.
>> >
>> >An example but this is from memory and only contains
the
>> short definition of
>> >the problem
>> >
>> >void MyFunction(int myFieldValue, DataSet ds)
>> >{
>> > MyAdap.SelectCommand.Parameters
["MyParamName"].Value
>> = myFieldValue;
>> > MyAdap.Fill(ds);
>> >}
>> >
>> >On my next call to this function it very obviously
goes
>> through the same
>> >process - using exactly the same adapter and command
>> object as before (they
>> >are the same instances) and i set the parameter value
as
>> before (as in the
>> >code) and call fill. This time it fails with a
similar
>> message to the one
>> >in the subject line (from memory) which i think we
have
>> all seen at some
>> >time or other.
>> >
>> >Does this mean a OdbcCommand can not be reused by
merely
>> reassigning new
>> >values to the parameters?
>> >
>> >For your info: If i were to prepare the statement
>> beforehand then it is
>> >fine - the same parameter in the same command in the
>> same adapter can be set
>> >multiple times and fill called multiple times - its
>> perfect. But that
>> >requires me to keep the connection open to create the
>> prepared statement
>> >which is not the intention for this stateful object
>> instance. The driver i
>> >use is Sql Server (for development) - and i note the
>> SqlClient namespace
>> >objects do not have this same problem?
>> >
>> >Anyone got any ideas or understanding on the problem?
>> >
>> >Thanks in advance
>> >
>> >Jason
>> >
>> >
>> >.
>> >
>
>
>.
>