Korzh.com developer tools forums :: View topic - select *
Korzh.com
home : Community forums  FAQFAQ   SearchSearch  |  RegisterRegister  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
select *

 
Post new topic   Reply to topic    Korzh.com developer tools Forum Index -> EasyQuery ASP.NET
View previous topic :: View next topic  
Author Message
lesafir
Novice


Joined: 28 Apr 2009
Posts: 3

PostPosted: Tue May 05, 2009 3:03 pm    Post subject: select * Reply with quote

Problem :

"Select *" for tables or views (vs. picking columns one at a time)

Solution :

If you do not define any columns in "Result columns" panel - then EasyQuery.NET will generate SELECT * in result SQL statement.

But, I have many tables in the selection. I have to choose the table before.

so ?
Back to top
View user's profile Send private message
Sergiy
Guru


Joined: 07 Nov 2005
Posts: 389

PostPosted: Tue May 05, 2009 9:37 pm    Post subject: Reply with quote

If you need to get
SELECT * FROM ...
then you just do not add any column in QueryColumnsPanel.

In case you need something like
SELECT Table1.* FROM ...
then you will need to define new virtual attribute in your data model with necessary expression ("Table1.*" in this case) and then add this new attribute in QueryColumnsPanel as a column
_________________
With the best regards, Sergiy Korzh.
Back to top
View user's profile Send private message
fporres
Novice


Joined: 15 Apr 2009
Posts: 4
Location: Valladolid, Spain

PostPosted: Mon May 11, 2009 2:05 pm    Post subject: select * Reply with quote

Hello everyone.

I'm newby in EasyQuery.NET and I'm trying to create a virtual attribute to display all table fields but I can't succeed.

I've been trying to add and remove some fields in the attribute but I allways get the same result:
Error in SQL statement: Incorrect syntax near the keyword 'AS'..

The SQL sentence generated is:
SELECT MyTableName.* AS "All table data" FROM MyTableName MyTableName

Does anyone know how to avoid the 'AS ...' and the double 'MyTablename MyTableName' syntax?


The code of my Virtual attibute in the XML file is:
Code:

<ATTR ID="*" KIND="Data" EXPR="*" CAPTION="All table data" TYPE="WideString" SIZE="300" QUOTE="False" UIC="True" UIR="True" UIS="True" UAL="True" AGGR="False" TABLES="MyTableName" >
   <OPERATORS>StartsWith,Contains,Equal,NotStartsWith,NotContains,NotEqual,InSubQuery,IsNull</OPERATORS>
   <EDITORS />
</ATTR>


Thank you so much for you help.
Back to top
View user's profile Send private message
Sergiy
Guru


Joined: 07 Nov 2005
Posts: 389

PostPosted: Wed May 13, 2009 12:36 pm    Post subject: Reply with quote

What database do you use? Most of databases understand "AS" keyword correctly.

But in any case it is not a problem. You can turn "AS" off through SqlFormats.UseColumnAliases property of Query object.
Just set it to ColumnAliasesUsage.Never value.
_________________
With the best regards, Sergiy Korzh.
Back to top
View user's profile Send private message
fporres
Novice


Joined: 15 Apr 2009
Posts: 4
Location: Valladolid, Spain

PostPosted: Thu May 14, 2009 8:54 am    Post subject: select * Reply with quote

Hello Segiy, thank you very much for your help.

I'm using SQL Server and there's no problem with 'AS' but the problem seems to be the place where 'AS' is placed in the SQL statement. I'm trying to avoid 'AS' like you say but I get the same results.

Here is a piece of code and how I'm trying to do it.

Code:

public partial class builder_builder : System.Web.UI.Page {
   ...
   private Korzh.Easy.QueryQuery query = new Query();
   private Korzh.EasyQuery.SqlFormats sqlFormats = new SqlFormats();
   ...

   protected void Page_Init(object sender, EventArgs e) {
      ...
      Korzh.EasyQuery.EntityAttrExpr.TextFormat = "{attr}";
      this.QueryPanel1.Appearance.AttrElementFormat = "{attr}";
      this.QueryColumnsPanel1.Appearance.AttrElementFormat = "{attr}";
      this.sqlFormats.UseColumnAliases = ColumnAliasesUsage.Never;
    }
   ...
}


Is there any place where I could find a detailed API of the EasyQuery components. The Example page is pretty simple and really don't know how it all is working. I've been checking the easy_query/start_asp.htm help page but it's not very helpful ...

Quote:
When the demo project is setup and compiled - then try to play with some properties of EasyQuery.NET components (Query, DataModel, QueryPanel and QueryColumnsPanel) to see what happen.


I think I missed some kind of connection between Sql object and sqlFormats object. Any ideas?

Thank you very much (again)
Back to top
View user's profile Send private message
fporres
Novice


Joined: 15 Apr 2009
Posts: 4
Location: Valladolid, Spain

PostPosted: Thu May 14, 2009 9:11 am    Post subject: select * Reply with quote

Forget it. Problem solved.

I realised that Korzh.EasyQuery.Query has a Format attribute where I can set the ColumnAliasesUsage to never.

Code:

Korzh.EasyQuery.query.Formats.UseColumnAliases = ColumnAliasesUsage.Never;


Thank you anyway.
Back to top
View user's profile Send private message
Sergiy
Guru


Joined: 07 Nov 2005
Posts: 389

PostPosted: Thu May 14, 2009 2:24 pm    Post subject: Reply with quote

Two suggestions:

1. You do not need to prefix your query variable with namespace.

2. It is better to create Query object once on session start as it is done in our sample project and the use it on any postback.
_________________
With the best regards, Sergiy Korzh.
Back to top
View user's profile Send private message
Sergiy
Guru


Joined: 07 Nov 2005
Posts: 389

PostPosted: Thu May 14, 2009 2:27 pm    Post subject: Reply with quote

One more thing:

Take a look at help files for EasyQuery.NET for full reference of library classes and their methods. Help files are placed in <install dir>\Help folder.
_________________
With the best regards, Sergiy Korzh.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Korzh.com developer tools Forum Index -> EasyQuery ASP.NET All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group