User Control taking up too much resources
-
What sort of user control that you are using ? i mean what it does ? Sreejith Nair [ My Articles ]
i've this main window form where it contains 4 user control. each of this user control connects to the database. after i added these user control onto my main form and run my program, my com became very lag. Chris
-
i've this main window form where it contains 4 user control. each of this user control connects to the database. after i added these user control onto my main form and run my program, my com became very lag. Chris
Try to create a class which do database communication insted of user controls. And try to get the reference of class which have the implimentation part of data access into your user control. Sreejith Nair [ My Articles ]
-
Try to create a class which do database communication insted of user controls. And try to get the reference of class which have the implimentation part of data access into your user control. Sreejith Nair [ My Articles ]
ok i try tt. thanks ;) chris
-
Try to create a class which do database communication insted of user controls. And try to get the reference of class which have the implimentation part of data access into your user control. Sreejith Nair [ My Articles ]
hi, i've managed to put the database connection coding into a separate class. namespace WindowsApplication2 { public class db1 { public OleDbConnection conn; public string display_SQL; public OleDbCommand display_cmd; public OleDbDataAdapter display_adapter; public DataSet display_ds; public db1() { conn = new System.Data.OleDb.OleDbConnection(); conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" + @"Data source =C:\Documents and Settings\Desktop\WindowsApplication2\bin\Debug\mydbms.mdb"; display_SQL = "SELECT * FROM tblYear"; display_cmd = new System.Data.OleDb.OleDbCommand (display_SQL, conn); display_adapter = new System.Data.OleDb.OleDbDataAdapter(display_cmd); display_ds = new System.Data.DataSet(); display_adapter.Fill(display_ds,"tblYear"); } } i'm not really good in using separate class.so how do we do these same connection into a function in this same class instead of doing it in the constructor? and how do we call that function from a button? anw is there a wweb site where they teach about windows classes which may assist more?? Chris
-
Try to create a class which do database communication insted of user controls. And try to get the reference of class which have the implimentation part of data access into your user control. Sreejith Nair [ My Articles ]
sorry i was wrong. :( i don't know how to call the function from a different class if i do a database connection in that function and not in the constructor of the separate class?? is it public void connection(){} or ??
-
sorry i was wrong. :( i don't know how to call the function from a different class if i do a database connection in that function and not in the constructor of the separate class?? is it public void connection(){} or ??
Handle it on button click. create an object of ur class Class DBConnection { public void Connect() { ....do ur code; } } Button1_Click() { DbConnection DbConn = new DBConnection(); DBConn.Connect(); } U can pass and return parameters too to this Connect Function; I hope I am up to ur expection...:-D Ketty
-
Handle it on button click. create an object of ur class Class DBConnection { public void Connect() { ....do ur code; } } Button1_Click() { DbConnection DbConn = new DBConnection(); DBConn.Connect(); } U can pass and return parameters too to this Connect Function; I hope I am up to ur expection...:-D Ketty
hey thanks a lot. but i've got one question:-D let say i've got this form which has a textbox and dataGrid. then i will create a separate class like wat u taught me. if my SQl statement goes like this: "Select * From Table Where Col1 ='" + textBox1.Text + "'";..... how should i pass in the textBox1.Text value to this connection function??
private void button1_Click(object sender, System.EventArgs e) { db1 a = new db1(); dataGrid1.DataSource = ?? dataGrid1.DataMember = ?? } Class DBConnection { public void Connect() { string SQL = "Select * From Table Where Col1 ='" + textBox1.Text + "'"; //?? ....do ur code; } }
Chris -
hey thanks a lot. but i've got one question:-D let say i've got this form which has a textbox and dataGrid. then i will create a separate class like wat u taught me. if my SQl statement goes like this: "Select * From Table Where Col1 ='" + textBox1.Text + "'";..... how should i pass in the textBox1.Text value to this connection function??
private void button1_Click(object sender, System.EventArgs e) { db1 a = new db1(); dataGrid1.DataSource = ?? dataGrid1.DataMember = ?? } Class DBConnection { public void Connect() { string SQL = "Select * From Table Where Col1 ='" + textBox1.Text + "'"; //?? ....do ur code; } }
ChrisIn that case private void button1_Click(object sender, System.EventArgs e) { db1 a = new db1(); dataGrid1.DataSource = Connect(txtbox1.text); dataGrid1.DataMember = ?? } Class DBConnection { public DataSet Connect(String TextVal) { DataSet ds = new DataSet(); string SQL = "Select * From Table Where Col1 ='" + TextVal + "'"; //?? ....do ur code; Return ds } } Is that fine now ;) Ketty
-
In that case private void button1_Click(object sender, System.EventArgs e) { db1 a = new db1(); dataGrid1.DataSource = Connect(txtbox1.text); dataGrid1.DataMember = ?? } Class DBConnection { public DataSet Connect(String TextVal) { DataSet ds = new DataSet(); string SQL = "Select * From Table Where Col1 ='" + TextVal + "'"; //?? ....do ur code; Return ds } } Is that fine now ;) Ketty
hi, thanks i managed to do it. but i got another problem.. i'v e got this class.. this is the function
class test { public void test ( string LD ) { LD = "haha"; } } // end of class test class Form1:System.Windows.Forms.Form { private void btnConvert_Click(object sender, System.EventArgs e) { string date; cL.CalendarConversion(date); // but date is null } }//end of class form1 i can't pass the value of LD from class test to date from class Form1.. why?
Chris -
hi, thanks i managed to do it. but i got another problem.. i'v e got this class.. this is the function
class test { public void test ( string LD ) { LD = "haha"; } } // end of class test class Form1:System.Windows.Forms.Form { private void btnConvert_Click(object sender, System.EventArgs e) { string date; cL.CalendarConversion(date); // but date is null } }//end of class form1 i can't pass the value of LD from class test to date from class Form1.. why?
Chrisclass test { public string test ( string LD ) { LD = "haha"; } } // end of class test class Form1:System.Windows.Forms.Form { private void btnConvert_Click(object sender, System.EventArgs e) { string date; test ts = new test(); date = ts.test(); cL.CalendarConversion(date); // date is not null now } }//end of class form1 Is this that u wanted? :confused: Ketty