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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top