C Board  

Go Back   C Board > General Programming Boards > C# Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 12-23-2003, 06:58 AM   #1
Registered User
 
Join Date: Apr 2003
Posts: 31
I have problem!!!

Hi
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;
and in the form (B) after inserting (save button)
CODE 2
Code:
A insertptr= new A();
// this function do the insert,delelte…….
insertptr.SQLserver("SQL statement",insertptr.sqlConnection1);
I have tried to solve this problem by using updeta(), refresh() , but it didn't work
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");
and in the load event for form (A)
CODE 4
Code:
		private void Cars_Showroom_Load(object sender, System.EventArgs e)
		{
			loadfun();

		}
and in the code number 2 see above I have put
Code:
	A New_Specification = new New_Specification();
	New_Specification.loadfun();
but unfortunately it didn't work, the strange is when I call it in the load it works, when I call it in anywhere form Form (A) it works, but when I call it from Form(B) it works but the update don't happen immediately I must restart the form or I must call that function (loadfun) from the form (A) which the function located.

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   Reply With Quote
Old 12-26-2003, 05:49 PM   #2
the hat of redundancy hat
 
nvoigt's Avatar
 
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   Reply With Quote
Old 12-29-2003, 01:07 AM   #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   Reply With Quote
Old 12-29-2003, 02:30 PM   #4
Registered User
 
datainjector's Avatar
 
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   Reply With Quote
Old 12-30-2003, 08:09 AM   #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;
but the striange is when i do this
Code:
// what i want is to close Form A
// all this in Form B
A n = new A();

n.visible=true;
it opens new Form A , My Q is why it works with open and doesn't work the close method???
Dragon227Slayer is offline   Reply With Quote
Old 12-30-2003, 09:42 AM   #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 the pointer n holds the handle of the Form A
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   Reply With Quote
Old 01-01-2004, 06:51 AM   #7
the hat of redundancy hat
 
nvoigt's Avatar
 
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   Reply With Quote
Old 01-08-2004, 03:23 AM   #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   Reply With Quote
Old 01-08-2004, 02:27 PM   #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   Reply With Quote
Old 01-21-2004, 03:49 AM   #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   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 08:12 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22