|
I have got my main form working OK now, but it's still the case that my form spawns another form, using ShowDialog, all buttons have a DialogResult of none, the AcceptButon and CancelButton are none in both dialogs, but when you click a button in the second, and my code calls this.Close(), the parent dialog closes also unless I put hacky bool variables in to stop it.
Why, why, why ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Please check whether you have put the this.Close() method call in the first form (i.e., parent form itself)instead of putting it in the click handler of the second form. If this is so, please put that code in the click handler of the button in the second form.
In fact, I tried to test it using a chain of three forms, Form1 calling Form2, and Form2 calling Form3. I have also put this.Close() in both Form2 and Form3 click handlers for the respective buttons. But I get the correct and expected behaviour and the parent form is not closed. Apparently, your problem is because of this.Close() being called from within a method in the parent form itself.
|
|
|
|
|
Ashok Dhamija wrote:
this.Close() being called from within a method in the parent form itself.
No, it's not. I've stepped through many times and verifed that it's not.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
May I suggest the following scheme, as I tested it in my test application:
In Form1, I put the following code for button1 to display Form2 as a modal dialog:
private void button1_Click(object sender, System.EventArgs e)
{
Form2 form2 = new Form2();
form2.ShowDialog();
}
Then, in Form2, I put 2 buttons, button1 (to display Form3 as a modal dialog) and button2 (to close Form2), with the following code:
private void button1_Click(object sender, System.EventArgs e)
{
Form3 form3 = new Form3();
form3.ShowDialog();
}
private void button2_Click(object sender, System.EventArgs e)
{
this.Close();
}
I have put button1 in Form3, with the code to close it as under:
private void button1_Click(object sender, System.EventArgs e)
{
this.Close();
}
Now, when I show Form2 and then Form3 as modal dialog boxes from buttons in Form1 and Form2 respectively, they are properly shown. Similarly, when I close Form3 by clicking button1 on it (which uses this.Close() method and of course it can contain other code before that), it closes properly, and the important thing is that Form2 (which is the parent form for Form3) is NOT closed in this manner. Likewise, when I close Form2 by clicking button2 on it by using this.Close() method, Form2 closes properly and again it is pertinent to note that the parent form Form1 is not closed.
So, in this manner, the whole behaviour is as expected and correct. The only important aspect to note is that:
1. I am using the simple form2.ShowDialog() method, without using the DialogResult. Secondly, the actual functionality is added on the dialog form itself in its various buttons (instead of putting the same directly in parent form in the format of if(dialogResult == DialogResult.OK), etc.).
I wonder whether your application can be suitably modified to this pattern.
I really do not know whether all this is of any use to you.
Regards,
|
|
|
|
|
Hi - this is pretty close to what I am doing. I suspect that my form has some code that the designer has failed to remove, which is causing this behaviour.
Thanks for helping.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
A little code will help to know the exact situation.
Maqsood Ahmed [MCP,C#]
Kolachi Advanced Technologies
http://www.kolachi.net
|
|
|
|
|
There is no code. No code that's relevant anyhow. The core issue is the values of the buttons, which are set in the designer.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Just a wild guess, but do your OK and Cancel buttons have their DialogResult property set to DialogResult.OK and DialogResult.Cancel?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
S. Senthil Kumar wrote:
Just a wild guess, but do your OK and Cancel buttons have their DialogResult property set to DialogResult.OK and DialogResult.Cancel?
No, sorry, I thought I said that. They are all set to (none).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hi could u please tell me how i can check my sql database to look for a stored procedure if exist or not, and if not exist how i can create it, please help me by code, i have to finish my project as soon as possible
Thanks alot
Hamody
|
|
|
|
|
Surely this should have gone in the SQL / ADO.NET forum.
The SQL code is:
IF NOT EXISTS (SELECT * FROM dbo.sysobjects
WHERE id = OBJECT_ID(N'[dbo].[StoredProcedureName]')
AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
CREATE PROCEDURE ....
If you need to run this through a C# application just ExecuteNonQuery() on the SqlCommand like this:
SqlCommand cmd = new SqlCommand(sqlStatement, myConnection);
cmd.ExecuteNonQuery(); The above assumes that you already have a connection and it is open. The sqlStatement is a string that contains the completed contents of the SQL code above.
Does this help?
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
ok thnaks, i found another way to check the existance of the procedure thw procedure id:
proc dbo.Showhierarchy
(
@index int
)
As
Begin
declare @FolderIndex int, @FolderName varchar(30)
set @FolderName = (select Name from pdbfolder where FolderIndex= @Index)
print replicate ('_', @@nestlevel *4) + @FolderName
set @FolderIndex = (select min(FolderIndex) from pdbfolder where parentfolderindex = @index)
while @FolderIndex is not null
begin
exec Showhierarchy @FolderIndex
set @FolderIndex = (select min (FolderIndex) from pdbfolder
where parentfolderindex =@index and FolderIndex > @FolderIndex)
End
End
....
so in the create satement that u emailed i write the above proc as it, and i need to get the two values which is printed @FolderIndex, @FolderName
note that it is a recurcive proc
could u send me the correctes code
Thanks alot
Hamody
|
|
|
|
|
Really, you should be creating stored procedures in advance of running your application - unless it is some sort of installation applicataion.
You are not going to get any data out of this in a C# application because there are no SELECT statements that return data out of the stored procedure. The only time you get print statements back is if an error occurs and the contents of any print statements is captured in the SqlException.
Anyway, to run a stored procedure this is the code you need in C#
SqlCommand cmd = new SqlCommand("Showhierarchy", myConnection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@index", indexValue);
cmd.ExecuteReader();
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
ok, when u execute it in the query analyzer u get a printed results i need them to be used in my code.
i don't know i think about inserting them in a table but the insert statement didn't execute in the proc that i sent to u ...
i don't know how to get these printed data ...
have u any idea
Thanks alot
Hamody
|
|
|
|
|
Hi
I have two projects and one of the project have internal methods which should be used in another project.. so i used friend assemly concept and was able to solve the problem partially... my problem is one of my projects have other refernced assemblies (third party also..) for which i dont have the code, which are not signed with a strong name. Now inorder to complete the process i have to sign the referenced assemblies as well.. How do i do that? Plz Help...
Regards
Deepak.S
|
|
|
|
|
If the assemblies have been delay signed then you can do it using the Strong Name Tool.
e.g.
sn.exe -R thirdparty.dll myKey.snk
|
|
|
|
|
|
I'm having a VERY hard time finding material I can read to understand this stuff. So far I got a program to evaluate mathematical equations and a basic Lexer that splits a string simply into a stack like so...
Example string - FunctionName ( "Param1" );
Stack[5]SEMICOLON
Stack[4]CLOSE_PAREN
Stack[3]"Param1"
Stack[2]OPEN_PAREN
Stack[1]FunctionName
Basically it tells me when it hits a special character, and after that it tells me what's inside it. I'm having a really hard time explaining this, a bunch of source is available here:
www.insolence9.com/downloads/SBN.zip
Thanks
|
|
|
|
|
Hi all
i need a bit help in saving images into mysql database through my C#.net application.I had converted the image into byte array but when i insert it or update the feild by an insert or update statement exception is thrown.
can anyone guide me pls
Thanks
Monica
|
|
|
|
|
First step in getting help in this situation is telling us WHAT exception is throw and what your code/database schema looks like.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Can u give me any article regrading saving images in mysql database .
The problem is when i try to insert this byte array through insert command to mysql table where the feild is a long blob to save that image this exception comes Out of scope. I donot know whether the way i am doing is right or not. but it saves the image in SQL server database not in mysql
What I am doing is converting the image from a picturebox in to a byte array and then trying to insert in the blob feild. I donot know it is write or wrong.if there is any other method pls tell me
thanks
Monica
|
|
|
|
|
|
hi I did the same thing which u suggested in that link but i am getting this exception
An unhandled exception of type 'System.Data.DBConcurrencyException' occurred in system.data.dll
Additional information: Concurrency violation: the UpdateCommand affected 0 records.
my code is like this
The table is tblPatientMaster with feilds one PatPhoto thats is long Blob and one patientId that is a bigint.
public static void UpdatePatientPhoto( long PatID,ref byte[] content )
{
DataRow PatRow;
String ConnectionString =
System.Configuration.ConfigurationSettings.AppSettings["DSN"];
String query= "Select* from tblpatientmaster where patientId = " +
PatID ;
OdbcConnection myConnection = new OdbcConnection(ConnectionString);
myConnection.Open();
OdbcDataAdapter myAdapter=new OdbcDataAdapter(query,myConnection);
DataSet ds= new DataSet("tblpatientmaster");
myAdapter.UpdateCommand = new OdbcCommand
("UPDATE tblpatientmaster SET " +
"PatPhoto = @iPHOTO " +
"WHERE patientId = @iPatNo", myConnection);
myAdapter.UpdateCommand.Parameters.Add("@iPHOTO", OdbcType.Binary,
content.Length, "patphoto");
myAdapter.UpdateCommand.Parameters.Add("@iPatNo", OdbcType.BigInt,
0, "patientId");
myAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
myAdapter.FillSchema(ds, SchemaType.Source, "tblpatientmaster");
myAdapter.Fill(ds,"tblpatientmaster");
DataTable PatTable = ds.Tables["tblpatientmaster"];
PatRow = PatTable.Rows.Find(PatID);
PatRow.BeginEdit();
if (content.Length != 0)
{
PatRow["PatPhoto"] = content;
}
PatRow.EndEdit();
myAdapter.Update(ds,"tblpatientmaster");
}
Pls anybody can help me with this problem.
Thanks
Monica
|
|
|
|
|
Relatively new to Web Apps (I've used them before, but was just reusing code, not creating). What I need is to display data read from a database in the following manner:
Header Header2 Header3
Item1 Item4 Item7
Item2 Item5 Item8
Item3 Item6
So basically 8 items will be read from a database, and it will group the items based on the common Header property. When it has displayed 3 I want it to go to the next line. Any advice?
|
|
|
|
|
Yeah, a repeater will give you the control you need here. Although, if it were me, I'd make things easier by writing a stored procedure that created three columns so that the presentation tier didn't need to worry about anything but displaying it.
Christian Graus - Microsoft MVP - C++
|
|
|
|