Hi Alex:
Alex said:
I'm using columns names with spaces. OK, I could change them, but...
Other code seems to work fine.
However the SQLCommandBuilder can't handle the spaces by default. If I look
at the generated insert sql statement I can see that it didn't do any
special treatment for the spaces.
I'm sure there must be a solution?
I see you found the solution but I'd seriuosly recommend changing the column
names. Not trying to preach but I've been burned by this way too bad. I
worked in a place where a guy who worked there for about a year loved using
spaces, special chars and reserved words for field names. So we used to
escape them and it took a lot of work to code around it. He would point out
that it's not that much work to use the braces and technically he was right.
But people constantly forgot to use the braces and we had a good amount of
turnover (ie new programmers) and contractors. It honestly got to the poitn
where we would spend probably 2 hours a week total on new queries that blew
up, figuring out why, fixing it etc. Those of us that worked there for a
while did it the least, but when you're in a hurry, it's easy to do and
since only the tables this guy (one person) created did this, you were used
to not having to do it and it was easy to make. Every new programmer would
make the mistake 5 or 6 times, then misdiagnose the problem, and someone
would have to look into it.
Anyway, I'll admit this was pretty extreme but it lasted for about 4 months
until the guy quit. The next day everyone unanimously agreed to work
overtime to change the fieldnames and modify the code. It took about 5
hours to make all of the changes (there was a ton of code) and test
correctly, but it was the best time investment I've ever seen. It paid for
itself in one week. To that end, I'm totally biased on this subject and
highly encourage others not to do it...hopefully I can save some other
people all those headaches.
Cheers,
Bill