Hi,
Oops, accidentally posted this to the C# group so apologies for cross
posting.
VS2008 IDE Desktop app.
Anybody out there deploying this db?
I am finding a strange problem with column names.
I am using an SQLCeCommand to create a datareader.
I have a where clause that is refusing some of the column names.
Saying the column name is not valid.
The columns are visible in Server explorer.
It seems to be column names that where added later on in the tables
design.
example of problem
"select * from unit where parent_id = 1" //fails, parent_id was added
after initial table construction
"select * from unit where id = 1" //works id was part of table
initial construction
A third party Database console has no problem running the queries
Code:
SqlCeConnection conn = new SqlCeConnection(mstrConnectionString);
//mstrConnection just has "DataSource = myFullPath\mydatabase.sdf
conn.Open();
string sql = "select * from unit where parent_id = 1";
SqlCeCommand cmd = new SqlCeCommand(sql,conn);
SqlCeDataReader r = cmd.ExecuteReader(); //DROPS DEAD
HERE with 'invalid column'
Appreciate any thoughts on the above.
Thanks
Bob
Ginny Caughey MVP - 22 Apr 2008 22:12 GMT
Are you sure the database at the location where you're looking does have
that column name? Can you execute any command on that connection? If you
execute the query select count(*) from information_schema.columns where
column_name = 'parent_id', do you get something greater than 0?
Ginny
> Hi,
> Oops, accidentally posted this to the C# group so apologies for cross
[quoted text clipped - 37 lines]
> Thanks
> Bob

Signature
Ginny Caughey
Device Application Development MVP
www.wasteworks.com
Software for Waste Management
bob - 24 Apr 2008 21:16 GMT
Hi Ginny,
Thanks for your reply.
Given that no else has struck this problem I must be doing something
wrong.
Unfortunately I have moved the DAL back to Access.
(Now targeting Framework 2.0 for the desktop version not because of
this problem)
When the app migrates onto a hand held I'll revisit the problem.
regards
Bob
>Are you sure the database at the location where you're looking does have
>that column name? Can you execute any command on that connection? If you
[quoted text clipped - 44 lines]
>> Thanks
>> Bob
tod_syncor - 13 May 2008 03:05 GMT
I don't know if you're using LINQ but I got burned by this once. I renamed
the field in the context but the "Source" property was still pointing to the
old column name. That caused my invalid column error.
Tod
> Hi,
> Oops, accidentally posted this to the C# group so apologies for cross
[quoted text clipped - 37 lines]
> Thanks
> Bob