I have something like that

SqlCommand cmd = new SqlCommand(sqlText, connection);
SqlDataReader data = cmd.Execute();
while (data.Read())
{
..do my stuff
}

When sqlText is invalid the error does not occur on cmd.Execute (as I
would expect) but on data.Read().

Is it the correct DotNet behaviour or some stupid setup on my PC?

Thanks

MH

Re: SQL Syntax error by Marina

Marina
Mon Mar 06 10:39:07 CST 2006

Are you sure this is the case? I've never heard of this, nor have I ever
experienced anything like that. Invalid SQL issues have always caused an
exception on the ExecuteReader line.

"Marius Horak" <nobody@eu.con> wrote in message
news:eUcAk$PQGHA.4976@TK2MSFTNGP11.phx.gbl...
>I have something like that
>
> SqlCommand cmd = new SqlCommand(sqlText, connection);
> SqlDataReader data = cmd.Execute();
> while (data.Read())
> {
> ..do my stuff
> }
>
> When sqlText is invalid the error does not occur on cmd.Execute (as I
> would expect) but on data.Read().
>
> Is it the correct DotNet behaviour or some stupid setup on my PC?
>
> Thanks
>
> MH
>



Re: SQL Syntax error by Marius

Marius
Tue Mar 07 02:35:17 CST 2006

Marina Levit [MVP] wrote:

> Are you sure this is the case? I've never heard of this, nor have I
> ever experienced anything like that. Invalid SQL issues have always
> caused an exception on the ExecuteReader line.

Of course I'm sure. It's why I'm asking here.
I think the problem is with having invalid search text for CONTAINS.
This will produce an error - CONTAINS(TEXT_COLUMN,'alpha beta')

MH