Click here to Skip to main content
15,896,359 members
Home / Discussions / C#
   

C#

 
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
GeneralStreet level mapping Pin
parrot12330-Oct-04 20:48
parrot12330-Oct-04 20:48 
GeneralRe: Street level mapping Pin
Colin Angus Mackay31-Oct-04 2:00
Colin Angus Mackay31-Oct-04 2:00 
GeneralApplication.EnableVisualStyles and Toolbar icons Pin
steve_rm30-Oct-04 20:08
steve_rm30-Oct-04 20:08 
GeneralRetriving Text Pin
abdo12345678930-Oct-04 11:20
abdo12345678930-Oct-04 11:20 
GeneralExecuting a file from an interface Pin
Kiran Satish30-Oct-04 11:05
Kiran Satish30-Oct-04 11:05 
GeneralRe: Executing a file from an interface Pin
Alex Korchemniy30-Oct-04 13:41
Alex Korchemniy30-Oct-04 13:41 
GeneralRe: Executing a file from an interface Pin
Kiran Satish31-Oct-04 7:13
Kiran Satish31-Oct-04 7:13 
GeneralRe: Executing a file from an interface Pin
Alex Korchemniy31-Oct-04 9:23
Alex Korchemniy31-Oct-04 9:23 
GeneralRe: Executing a file from an interface Pin
Kiran Satish31-Oct-04 9:49
Kiran Satish31-Oct-04 9:49 
GeneralNeed idea for a neural network... Pin
tom_dx30-Oct-04 10:52
tom_dx30-Oct-04 10:52 
GeneralRe: Need idea for a neural network... Pin
Alex Korchemniy30-Oct-04 11:01
Alex Korchemniy30-Oct-04 11:01 
GeneralRe: Need idea for a neural network... Pin
tom_dx30-Oct-04 11:17
tom_dx30-Oct-04 11:17 
GeneralRe: Need idea for a neural network... Pin
yoaz31-Oct-04 2:14
yoaz31-Oct-04 2:14 
QuestionHow to get a string's encoding Pin
Matt Gerrans30-Oct-04 9:52
Matt Gerrans30-Oct-04 9:52 
AnswerRe: How to get a string's encoding Pin
Heath Stewart31-Oct-04 9:21
protectorHeath Stewart31-Oct-04 9:21 
GeneralRe: How to get a string's encoding Pin
Matt Gerrans1-Nov-04 5:01
Matt Gerrans1-Nov-04 5:01 
GeneralRe: How to get a string's encoding Pin
Heath Stewart1-Nov-04 5:30
protectorHeath Stewart1-Nov-04 5:30 

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.