RE: Selecting data from recordset
Posted: 6/18/2004 4:06:33 PM
By: Comfortably Anonymous
Times Read: 1,744
0 Dislikes: 0
Topic: Programming: .NET Framework
Parent Message
Well, still haven't figured that one out yet, and I'm now doubting that an ADO recordset is "intelligent" enough to do so. But using the ADO.NET .ExecuteScalar method (Returns only one row) and setting X & Y both to Primary Keys, I am able to get sufficiently quick response to do what I was doing.

I created the following method:

public int getTerrainByXYW(int X, int Y, int World)
/// Returns the terrain for a single cell
{
string qTerrain = "SELECT Terrain FROM Geo WHERE X=" + X +
" AND Y=" + Y + " AND World=" + World;

SqlCommand cmdTerrain = new SqlCommand(qTerrain, dbCon);

int Terrain = (int)cmdTerrain.ExecuteScalar();

return Terrain;
}

I found I am able to populate a 25x25 grid in less than a second. Although it seems wasteful to use 625 separate queries (All using the same existing database query, so there's no "create a new connection" overhead), the performance is surprisingly good. The trick was to set multiple primary keys, before that it was taking a LONG time.
Rating: (You must be logged in to vote)