![]() |
| | #1 |
| Registered User Join Date: Apr 2003
Posts: 31
| I have problem!!! Please I have a problem I have created a program deals with data base for ( cars showroom), I will illustrate the problem Suppose form (A) has the connection & data grid and every think necessary, and form (B) which used for inserting cars for instance. When the insertion operation complete the data grid don't update but the actual data has been updated in the data base so I have to close the form (A) then run it again and after that the changes happened ( note : my program working but the data grid don't update immediately ) I must mention that I have use the object technique So when I say open form (B) for insert CODE 1 Code: Form ptr= new B(); B.visible=true; CODE 2 Code:
A insertptr= new A();
// this function do the insert,delelte…….
insertptr.SQLserver("SQL statement",insertptr.sqlConnection1);
Also I have do this , I created public function in form (A) CODE 3 Code: public void loadfun()
{
this.sqlConnection1.Open();
this.dataSet1.Clear();
this.sqlDataAdapter1.SelectCommand.CommandText = "SELECT * FROM CarSpecifications ORDER BY CarName,Class,Model,SpecificationId";
this.sqlDataAdapter1.Fill(dataSet1,"CarSpecifications");
this.sqlConnection1.Close();
dataGrid1.SetDataBinding(dataSet1,"CarSpecifications");
CODE 4 Code:
private void Cars_Showroom_Load(object sender, System.EventArgs e)
{
loadfun();
}
Code: A New_Specification = new New_Specification(); New_Specification.loadfun(); i hope that I could explain the problem very well so that u can help me Note: I don't have any syntax error and I am very sure form code coz the program work properly . |
| Dragon227Slayer is offline | |
| | #2 |
| the hat of redundancy hat Join Date: Aug 2001 Location: Hannover, Germany
Posts: 2,769
| If the function works when you call it from Form A, then in Form A put it after the ShowDialog of Form B like this: (in buttonpress or something) FormB b = new FormB(); FormB.ShowDialog(); loadfun();
__________________ hth -nv She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate." When in doubt, read the FAQ. Then ask a smart question. |
| nvoigt is offline | |
| | #3 |
| Registered User Join Date: Apr 2003
Posts: 31
| Thanks Mr. nvoigt But I think this will not solve my problem because ur opening a new form (A | B) and what I want is to update the form (A | B ) itself without creating new form. Also I think closing the form and then open it again more efficient than create new one, but this will cause losing the information that have been written in the ( textbox) . Again thank u very much Mr. nvoigt If anybody has any answer please submit it immediately thanks |
| Dragon227Slayer is offline | |
| | #4 |
| Registered User Join Date: Mar 2002
Posts: 356
| have u tried the onFocus event ??in the OnFocus event of form a just read back the data into the dataGrid...
__________________ "I wish i could wish my wishs away" "By indirections find directions out" -- William Shakespears "Do what thou wilt shall be the whole of the law" -- Crowley "THE BEAST 666" Mizra -> love = Death... RDB(Rocks yooo).. http://www.cbeginnersunited.com Are you ready for the Trix ??? |
| datainjector is offline | |
| | #5 |
| Registered User Join Date: Apr 2003
Posts: 31
| no it doesn't work please can u help me in another way i want to close Form A from Form B how can do that coz i have tried this Code: // what i want is to close Form A // all this in Form B A n = new A(); n.close(); // also i have tried this n.visible=false; Code: // what i want is to close Form A // all this in Form B A n = new A(); n.visible=true; |
| Dragon227Slayer is offline | |
| | #6 |
| Registered User Join Date: Apr 2003
Posts: 31
| Hi i thank i have understood the problem but still can not be able to solve it if i want to change any thing in Form A from the Form B i must get the pointer that points to the actual Form A suppose we create the Form A in Form Q Code: // all in Form Q A n = new A(); n.show(); so if i want to change Form A in(from) the Form B I must get the value of n i know it confuses but please try to help meeeeeeeeeeeee how can I get the value of n then use it in form B |
| Dragon227Slayer is offline | |
| | #7 |
| the hat of redundancy hat Join Date: Aug 2001 Location: Hannover, Germany
Posts: 2,769
| Most controls have a parent. I'm not sure if forms have a parent form, I'm not at a development computer right now. If they don't, make your constructor of form B take an agrument of type A. in FormA: FormB x = new FormB( this );
__________________ hth -nv She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate." When in doubt, read the FAQ. Then ask a smart question. |
| nvoigt is offline | |
| | #8 |
| Registered User Join Date: Apr 2003
Posts: 31
| hi my friend thank u very much for help but this satement generates syntax error |
| Dragon227Slayer is offline | |
| | #9 |
| Registered User Join Date: Jan 2003
Posts: 648
| I'll be able to help you if you post the code for the forms, all of it except maybe your calculations etc. |
| Speedy5 is offline | |
| | #10 |
| Registered User Join Date: Apr 2003
Posts: 31
| thank u Mr. speedy5 but i think there is no benefit from posting the code also it is too large i have explained the problem very well above but if u want, i will send it in text file to your E-mail thanks |
| Dragon227Slayer is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need help understanding a problem | dnguyen1022 | C++ Programming | 2 | 04-29-2009 04:21 PM |
| Memory problem with Borland C 3.1 | AZ1699 | C Programming | 16 | 11-16-2007 11:22 AM |
| Someone having same problem with Code Block? | ofayto | C++ Programming | 1 | 07-12-2007 08:38 AM |
| A question related to strcmp | meili100 | C++ Programming | 6 | 07-07-2007 02:51 PM |
| WS_POPUP, continuation of old problem | blurrymadness | Windows Programming | 1 | 04-20-2007 06:54 PM |