[FIXED] sql error?

Posts   
 
    
mike
User
Posts: 24
Joined: 02-Oct-2003
# Posted on: 09-Oct-2003 01:45:17   

Hi, can anyone help me with the following error. I'm trying to do a select * from a table1 to view all the entries using llblgen's method calls and I'm receiving the following error message when I run it:

A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll

Additional information: System error.

An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll

Additional information: System error.

Unhandled Exception: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'Order'.

There is a relationship between 2 tables ie table1 also contains the FK for table2 Here is the section of code that is causing the error.

public void viewTransTable (object sender, EventArgs e) { SyTranHDRCollection viewAll = new SyTranHDRCollection(); viewAll.GetMulti(null); transDG.DataSource = viewAll; }

thanks Mike

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 09-Oct-2003 09:13:54   

Can you please step into the debugger from the GetMulti() line to the line that looks like:

IRetrievalQuery selectQuery = Dynamic....

in the SyTranHDRDAO object? When you step OVER that line, go to the command window in visual studio and type:

?((RetrievalQuery)selectQuery).ToString()

This will display the query that is being executed. Can you paste that query here please? Thanks. simple_smile

Frans Bouma | Lead developer LLBLGen Pro
mike
User
Posts: 24
Joined: 02-Oct-2003
# Posted on: 09-Oct-2003 18:51:42   

Thanks, the problem was the use of reserved words such as "order" in the fields of the table.

Mike

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 09-Oct-2003 21:41:25   

mike wrote:

Thanks, the problem was the use of reserved words such as "order" in the fields of the table.

Mike

Ok, this shouldn't be a problem, as the fields should be surrounded with [ and ]. Were your fields surrounded with those characters in the query? I'll look into the DQE better adding these, because 'order' should be a normal field name.

Frans Bouma | Lead developer LLBLGen Pro
gez
User
Posts: 5
Joined: 02-Oct-2003
# Posted on: 10-Oct-2003 00:33:55   

hi, yes the names were surround by [ ] however the program did not seem to parse it correctly creating the sql error. But after changing the name to something other than a sql reserved word, it worked perfectly.

Mike

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 10-Oct-2003 11:26:54   

I can reproduce it when I rename a field to 'Order'. When you rename a field, you'll get an alias in the query, and that alias name doesn't have '[]' around itself, which then doesn't work.

This is a bug, I'll fix this and will release it with the bugfix for the weak relations, probably saturday or monday.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 10-Oct-2003 13:19:54   

This is fixed in the next release of the SqlServer DQE.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 14-Oct-2003 10:37:44   

The fix is now available. (14-oct-2003 Runtime library release). This fix eliminates the issue with 'reserved keywords' as field names, when it comes to T-SQL.

Frans Bouma | Lead developer LLBLGen Pro