Dynamically created data source for GridView

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I have a SQL string on the lines;

"SELECT a,b, c FROM MyTable WHERE MyTable.d = '" & Me.MyField.text & "'"

The value of Me.MyField is provided at runtime by user. I need to assign the
resultset of this SQL to an UltraGrid for view only i.e. no editing just
display. My questions are;

1. What is the fastest way to assign the result of SQL string to the
UltarGrid as speed is of essence on runtime?

2. If the value of Me.MyField.text is changed by user then what code can I
use to refresh the UltraGrid with the new resultset?

Thanks

Regards
 
John,

You might consider using a command object's ExecuteReader method to execute
the SQL statement and return the resultset in a datareader.

Then load the data from the datareader into a datatable using the
datatable's Load method, which accepts a datareader.

Finally, apply the datatable to the gridview's DataSource property.

Kerry Moorman
 
Back
Top