|
How do you count the number of controls on a C# form. I mean suppose i have 3 textboxes on the form, i want my countr to return '3'.
|
|
|
|
|
Depends on how the controls are arranged in the form. If all are jst plain on the form form.Controls.Count should do what you want. If some controls sit within other controls (like panels, groupboxes etc) you will have to count recursively:
private int CountControls(Control control){
int result = 0;
foreach (Control subControl in control.Controls){
result++;
result += CountControls(subControl);
}
return result;
}
|
|
|
|
|
|
We need to implement better security into a C# Windows Desktop Application we are building, and are hoping to get best practices recommendations on the following:
1) "encrypted username / passwords" for connection strings -- actually any technique that will hide the connection string specifics from the user once, the application is built and put into an executable -- possibly by using the Registry.
2) Use of XML for pooling connection strings and the storing of username / passwords in the XML string: building a connection string based on settings in an XML File -- in some encrypted form... see 1) above...
3) NT Authentication for user login.
Thanks for any information you can give us.
Anne
|
|
|
|
|
I created a client application and it was working just fine on my machine but when I tried to install it to another machine it was giving me following error. Does any one know how to fix this?
Error:
An Error Occured: Unable to find an entry point named OCIEnvCreate in DLL oci.dll.
Stack Trace:
at System.Data.OracleClient.DBObjectPool.GetObject(Object owningObject, Boolean& isInTransaction)
at System.Data.OracleClient.OracleConnectionPoolManager.GetPooledConnection(String encryptedConnectionString, OracleConnectionString options, OracleConnection owningObject, Boolean& isInTransaction)
at System.Data.OracleClient.OracleConnection.OpenInternal(OracleConnectionString parsedConnectionString, Object transact)
at System.Data.OracleClient.OracleConnection.Open()
at Invoice.Invoice.TransferData()
Also, how can you tell what version of oracle client is installed on your machine? Thank a lot in advance.
|
|
|
|
|
Hello,
I have:
SqlDataAdapter adapter = new SqlDataAdapter (conn.CreateCommand());<br />
adapter.SelectCommand.CommandText = "CREATE TABLE ea_CashFlowTest.....";<br />
adapter.Fill (this.dataset, "MyTable");<br />
;
Is there a way of executing this command:
adapter.SelectCommand.CommandText = "DROP TABLE ea_CashFlowTest";
So I can drop the table when I need to.
Thank you.
-- modified at 12:24 Tuesday 13th September, 2005
|
|
|
|
|
If you have sufficient permission you can call SqlCommand.ExecuteNonQuery();
MCAD
|
|
|
|
|
|
It looks like you are stuck in the mentality of using DataAdapters for everything. Remember that they are just higher level wrappers around existing functionality that is exposed else where. You are creating larger bulkier objects to do work that can easily be achieved with smaller more dynamic objects.
You should just create a SqlConnection and SqlCommand object and call ExecuteNonQuery() on it. e.g.
SqlConnection conn = new SqlConnection(myConnectionString);
SqlCommand cmd = new SqlCommand("DROP TABLE ea_CashFlowTest", conn);
try
{
conn.Open();
cmd.ExecuteNonQuery();
}
catch(SqlException ex)
{
}
finally
{
conn.Close();
}
I hope this helps.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
Thanks, I figured it out.
|
|
|
|
|
Hello,
Is there a way of adding a second header column to datagrid?
For example: first header will have "Pd1", "Pd2" .... headings
second header will have: "Jan", Feb", ...... headings.
Thank you
|
|
|
|
|
I try to call a java webservice from .NET. When calling one of the Webservice methods I get the error:
"There is an error in XML document (1, 339)".
I tracked down the SOAP XML response by a Tool called "TCPMonitor":
-------------------------------------------------------------------------------------
HTTP/1.1 100 Continue<br />
<br />
HTTP/1.1 200 OK<br />
Content-Type: text/xml;charset=utf-8<br />
Transfer-Encoding: chunked<br />
Date: Mon, 05 Sep 2005 17:07:28 GMT<br />
Server: Apache-Coyote/1.1<br />
<br />
2000<br />
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope<br />
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"<br />
xmlns:xsd="http://www.w3.org/2001/XMLSchema" <br />
...
-------------------------------------------------------------------------------------
I discovered that "Transfer-Encoding: chunked" and the "2000" mean, that the SOAP response is sended in chunked parts of 2000 (bits, characters ???) by the webserver. .NET doesn´t seem to be able to join the chunked parts back to one.
At least my question:
1. Is it possible to call the webmethod in C#, declaring to use only http/1.0? (to avoid the chunking of http/1.1)
or
2. Is it possible for .NET to read http/1.1, chunked SOAP messages in some way?
I still have to use .NET 1.1, so please do not refer to .Net 2.0.
(Sorry for the long text, but I thought the information could be interresting to anybody else with the same problem)
Thanks for any response
|
|
|
|
|
I try to call a java webservice from .NET. When calling one of the Webservice methods I get the error:
"There is an error in XML document (1, 339)".
I tracked down the SOAP XML response by a Tool called "TCPMonitor":
-------------------------------------------------------------------------------------
HTTP/1.1 100 Continue<br />
<br />
HTTP/1.1 200 OK<br />
Content-Type: text/xml;charset=utf-8<br />
Transfer-Encoding: chunked<br />
Date: Mon, 05 Sep 2005 17:07:28 GMT<br />
Server: Apache-Coyote/1.1<br />
<br />
2000<br />
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope<br />
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"<br />
xmlns:xsd="http://www.w3.org/2001/XMLSchema" <br />
...
-------------------------------------------------------------------------------------
I discovered that "Transfer-Encoding: chunked" and the "2000" mean, that the SOAP response is sended in chunked parts of 2000 (bits, characters ???) by the webserver. .NET doesn´t seem to be able to join the chunked parts back to one.
At least my question:
1. Is it possible to call the webmethod in C#, declaring to use only http/1.0? (to avoid the chunking of http/1.1)
or
2. Is it possible for .NET to read http/1.1, chunked SOAP messages in some way?
I still have to use .NET 1.1, so please do not refer to .Net 2.0.
(Sorry for the long text, but I thought the information could be interresting to anybody else with the same problem)
Thanks for any response
|
|
|
|
|
I ran into this problem a few years ago. I think the solution was to override GetWebRequest like this
override WebRequest GetWebRequest(Uri uri)
{
WebRequest request = base.GetWebRequest(uri);
request.ProtocolVersion = Version.Version10;
return request;
}
You probably have to do some casting and type checking for this to work, but I think this will do it.
I can imagine the sinking feeling one would have after ordering my book,
only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
|
|
|
|
|
I want to be able to create 2 forms when I press a button. I am using the following code.
{
frmMy1 frm1 = new frmMy1();
frmMy2 frm2 = new frmMy2();
frm1.ShowDialog(this);
frm2.ShowDialog(this);
frm1.Dispose();
frm1.Dispose();
}
When I run this I have to close the first form before the second form is displayed. Is there any way to get them both up at the same time.
Thanks
Liam
|
|
|
|
|
There are two ways to show forms: modal and nonmodal. Modal means that the form being displayed must be closed before any further execution. This is like when you close Notepad before saving and it asks you if you would like to save. You MUST answer the question (and close the form) before you can click on the main notepad form or continue doing anything else in Notepad. This also means that your code blocks until that form is closed. In other words, frm2.ShowDialog(this); doesnt execute until frm1 is closed. The second, nonmodal, does not have these restrictions and is simply a normal form.
In .NET, the Form class has two methods, Show() and ShowDialog(). Show corresponds to a nonmodal form, and ShowDialog() corresponds to a modal form. To fix your problem, simply use Show() instead of ShowDialog().
|
|
|
|
|
Since ShowDialog() is a blocking call that returns a value, you can only have one Dialog open at a time. If you want both forms to be open, and usable at the same time, you'll have to show both forms using their Show() method, not ShowDialog() .
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Ok I can see how Show instead of ShowDialog might work but I will add extra requirements.
Perhaps my requirements are that I want to ensure that frm1 is always above the main form. And also frm2 is always above frm1. Even if the main display is selected I do not want frm1 and frm2 to be lost behind the main form.
With a modal form this is the case but if it is modeless form then it looses that feature.
How do I get around it. I know this sounds silly but can I have a modal form that itseld creates a modal form? i.e. frm1 is modal based on the main form, and also frm2 is modal based on frm2?
Thanks,
Liam
|
|
|
|
|
Yes you can put a modal form on another (though in most cases it is not a correnct implementation)
In any way, is it necessary that frm1 will pop up and immediatly frm2 will pop up above it? or is frm2 dependent on an action in frm1 (which is a more likely option)?
If your case is the first case (i.e. frm1 should open an immediatly open frm2) - you should open frm2 from frm1's OnActivate method. just override it, call the base and open the frm2 using the ShowDialog method.
However, i recommend not doing so since it does not seem the right thing to do.
If you are using option 2 then there is no problem. When a certain event occurs in frm1 (such as button_click), simply open the frm2 and you will get a modal from on a modal form on your main form.
Good luck, hope this answers your question.
|
|
|
|
|
My exact situation is:-
Form1 is created from a button press on the main form.
Form2 is created on a timer event. When the timer elapes form1 may or may not be present. If not it should be created. If it is form2 is displayed.
But Form2 must always be at the top and main form always at the bottom. If I use modeless formas and select the main form then form1 and form2 are hidden - not what I want.
Thanks,
Liam
|
|
|
|
|
I didn't quite follow what the requirement is, but did you consider placing frm2 together with the main form in an MDI frame? This way they can remain open while still being non-modal. You can use docking on the MDI frame to dock the frm2 to the bottom and the set the main form to fill the rest of the screen.
Also if you can specify what are the roles of each form it might be easier to understand.
Good Luck!
|
|
|
|
|
I am drawing a polygon by drawing lines on mouseup. after closing the figure the two points are not behaving as one.
Where did i went wrong.
Any help
|
|
|
|
|
Begineer wrote:
after closing the figure the two points are not behaving as one
This is really vague. What do you mean by "not behaving as one"?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Sorry for not being able to explain my problem better.
I am drawing a polygon by positioning the mouse. when i choose the option close figure i am drawing a line from the current point to starting point.
After that it is not behaving as a closed figure. when i tried to drag i am able to drag two differnet lines on that last point.
Am i making sense.
|
|
|
|
|
Begineer wrote:
After that it is not behaving as a closed figure. when i tried to drag i am able to drag two differnet lines on that last point.
Try to drag what? One of the lines? Points? It sounds like your code isn't picking the correct points in your point array. Without seeing your drawing and dragging code, it's very difficult to say anything more.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|