Click here to Skip to main content
15,918,668 members
Home / Discussions / C#
   

C#

 
GeneralRe: Reflection help - child classes Pin
David Wengier31-Oct-04 17:04
David Wengier31-Oct-04 17:04 
GeneralDownloader and Install files from the WEB (Like the Windows Updates) Pin
programming31-Oct-04 12:04
programming31-Oct-04 12:04 
GeneralRe: Downloader and Install files from the WEB (Like the Windows Updates) Pin
kaptaintens31-Oct-04 13:25
kaptaintens31-Oct-04 13:25 
GeneralVirtual network IPs Pin
bouli31-Oct-04 8:27
bouli31-Oct-04 8:27 
GeneralRe: Virtual network IPs Pin
Dave Kreskowiak1-Nov-04 3:21
mveDave Kreskowiak1-Nov-04 3:21 
GeneralRe: Virtual network IPs Pin
bouli1-Nov-04 4:15
bouli1-Nov-04 4:15 
GeneralRe: Virtual network IPs Pin
Dave Kreskowiak1-Nov-04 6:21
mveDave Kreskowiak1-Nov-04 6:21 
GeneralSetItemData Pin
bouli31-Oct-04 6:54
bouli31-Oct-04 6:54 
GeneralRe: SetItemData Pin
c#amateur31-Oct-04 11:33
c#amateur31-Oct-04 11:33 
GeneralRe: SetItemData Pin
bouli31-Oct-04 11:38
bouli31-Oct-04 11:38 
GeneralRe: SetItemData Pin
Luis Alonso Ramos31-Oct-04 12:31
Luis Alonso Ramos31-Oct-04 12:31 
GeneralRe: SetItemData Pin
bouli31-Oct-04 23:54
bouli31-Oct-04 23:54 
General.xml to .doc,.html,.rtf Pin
makakiu31-Oct-04 5:36
makakiu31-Oct-04 5:36 
GeneralRe: .xml to .doc,.html,.rtf Pin
Christian Graus31-Oct-04 8:26
protectorChristian Graus31-Oct-04 8:26 
QuestionWhat's the problem? Pin
momer31-Oct-04 5:15
momer31-Oct-04 5:15 
AnswerRe: What's the problem? Pin
Stefan Troschuetz31-Oct-04 7:00
Stefan Troschuetz31-Oct-04 7:00 
GeneralRe: What's the problem? Pin
momer31-Oct-04 7:25
momer31-Oct-04 7:25 
GeneralUploade file to server problem! Pin
QzRz31-Oct-04 4:58
QzRz31-Oct-04 4:58 
Generalbound control looses changes after leaving panel Pin
Peter Kiesel31-Oct-04 3:25
Peter Kiesel31-Oct-04 3:25 
GeneralOverflow exception Pin
Ahmed Galal31-Oct-04 1:26
Ahmed Galal31-Oct-04 1:26 
GeneralRe: Overflow exception, a question Pin
yoaz31-Oct-04 2:20
yoaz31-Oct-04 2:20 
GeneralRe: Overflow exception, a question Pin
Ahmed Galal31-Oct-04 21:49
Ahmed Galal31-Oct-04 21:49 
GeneralDataSet - scalability Pin
devvvy30-Oct-04 23:14
devvvy30-Oct-04 23:14 
GeneralRe: DataSet - scalability Pin
Alex Korchemniy31-Oct-04 9:40
Alex Korchemniy31-Oct-04 9:40 
GeneralRe: DataSet - scalability Pin
devvvy31-Oct-04 16:49
devvvy31-Oct-04 16:49 
Yes, I can ask user to specify a WHERE clause, but solution would be nicer if I dont have to. I think you're right though - the whole point of DataSet is grab all data from SQLAdapter and work disconnected from data source - propagating changes only back to source only when you're all done in the end.

DataGrid.DataSource is anything that implements IEnumerable - Classes that implements this interface includes DataView, ArrayList, and Hashtable. IEnumerable includes one interface method:

IEnumerator GetEnumerator();

Which returns IEnumerator interface - which includes three interface methods:
1. object Current {get;}
2. bool MoveNext();
3. void Reset();

I think one can implement their own IList class, which resembles this:


class CustomerList : IList {
protected int _count=0;
protected Customer _current=null;

protected SQLConnection _con=null;
protected String _sql=null;

public CustomerList(String sql, ref SQLConnection con) {
_sql=sql;
_con=con;
}

property Object Current {
get {return _current;}
}

property int Count {
get {return _count;}
}

bool MoveNext() {
...grab directly from database everytime...
Customer cs=null;
int currentUIN=_current.getUIN() +1;

String filter=" WHERE UIN=" +currentUIN;
String sql=_sql +filter;
SqlCommand cmd= new SqlCommand(sql, _con);
_con.Open();
SqlDataReader rdr= cmd.ExecuteReader();
if(rdr.Read()) {
cs=new Customer();
cs.UIN=currentUIN;
cs.login=res.GetSqlString();
cs.email=res.GetSqlString();
... the rest of it...

_current=cs;

_con.Close();

//Get total count: "SELECT COUNT(*) FROM Customers"
... implementation ...

return true;
} else {
return false;
}
}

void Reset () {...}
}


Then, consuming it:

SQLConnection con=...;
String sql="SELECT * FROM CUSTOMERS;"
MyArrayList customerList= new MyArrayList(sql, con);
dgCustomers.DataSource = customerList;


Of course, you don't get the convenience of SQLDataAdapter.Update(), which propagate changes back in a batch --- ... is it possible to blend DataSet (100% disconnected) and CustomerList (100% connected, grab data as you go) and have the better of the two...

Norman Fung

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.