开发者

strange coldfusion errors after ms sql server table change

I am working with ColdFusion 9 on a Windows Server, using MS SQL Server 2005. I am encountering a strange issue.

I am creating an object by querying a table in the database, getting the necessary info, and building the object from the results. So if my table has these columns:

id
name
address

I am creating an object with methods such as get_id(), get_name(), get_address(), etc. All this works fine and when I query those methods I get the results I expect.

But now I go in and change the table. I add a new column, such as "city". All is ok, the object still instantiates. But now I go in and put some data into that new column. Now my object instantiation no longer functions. I am getting generic errors like this:

element ADDRESS is undefined in instance

I notice that I still have cftry tags wrapped around the cfquery statement, so I take those off. Now I see this error:

unsupported data conversion

So I go to the database and I delete the new column completely. Now everything works correctly, as before. So it seems that when I add a new column to this table, SQL Server is trying to do some sort of data conversion on it? I开发者_开发知识库 don't see where I have that flagged to happen anywhere.

Any help that can be given will be much appreciated!


Check to make sure that your query isn't using SELECT * to get the columns. SQL server can cache the execution plans and not return columns that have been added if you're using SELECT *.

Another way to fix it is to simply add a line break, or anything else, into the query so that SQL server will create a new execution plan.

Either way, stay away from SELECT *, as it's less performant, and can definitely lead to issues like this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜