SQL Syntax error

  • Thread starter Thread starter Marius Horak
  • Start date Start date
M

Marius Horak

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
 
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.
 
Marina said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top