Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Alias" versus "SQL Statement" Property

Status
Not open for further replies.

Toman

Technical User
Mar 30, 2004
190
CZ
Could someone explain the real difference between RecordSourceType "Alias" and "SQL Statement" in a grid when data for a grid comes from SQL. I don't mean slight differences in coding (I'm able to use them both), but like to know which method is preferable.

Thank you, Tom.
 
Hi Tom,

It's really fairly simple. When you set the RecordSourceType to "SQL Statement", you have to actually type a SQL SELECT statement into the RecordSource property. The statement will then generate a cursor, which becomes the data source for the grid.

By contrast, when you use "Alias", you supply the alias of any view, cursor or open table.

Personally, I've never seen the point of using "SQL Statement" because "Alias" in effect lets you do the same thing, and more. If I want to use a SELECT to populate a grid, I would run the SELECT first (to create a cursor), then use that cursor as the RecordSource.

If anyone knows any good reason to use "SQL Statement", I'd be interested to hear it. Otherwise, I suggest you just ignore it.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi Mike,

well, that’s probably me, the only one person using "SQL Statement" property for grid data.

I though "FoxPro wants me" to do it when using data from SQL. Nevertheless I was in doubt (it was the reason to post to TekTips). But only you freed me now from writing thisform.grid1.RecordSource = "SELECT * … into cursor temp" instead of simple SELECT * … into cursor temp.

One question remains: how this practically needless property could live out 9 version of our beloved program or what was the sense of it in the beginning.

Thank you, Tom
 
In a listbox or combobox, where you have a rowsource and rowsourcetype of SQL Statement and you have a Requery()-Method, that Requery() really does requery using that SQL Statement.

For Grids there is no requery(), only refresh(), but I also do not make use of sql statement recordsourcetype in grids.

In fact if you don't want a browse caused you need to write INTO CURSOR xyz and then xyz is the recordsource alias anyway.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top