|
Hi there!
Try this:
Add the following criteria to the ODBC connection string, after the datasource.
If there are no headers (as it is with your case): "HDR=NO;"
Otherwise: "HDR=Yes;"
Hope this helps!
modified 11-Apr-12 2:51am.
|
|
|
|
|
thanks.. its working now
i resolved it with oledb by specifiying HDR=NO
|
|
|
|
|
Hi Guys,
The random number in c# using System.Random.NextDouble() is not returning a good set of random numbers over 10000 iterations, there seems to be concentration for a consecutive iterations on set of values, my code looks like this
System.IO.StreamWriter file = new System.IO.StreamWriter("c:\\test.txt");
for (int i=0;i<10000;i++)
{
RandomNumber = new Random();
string lines = "iterationCount"+ ":"+" "+i.ToString()+ " "+RandomNumber.NextDouble().ToString();
file.WriteLine(lines);
//}
}
file.Close();
is there a better way of generatin random numbers in c#?
Many Thanks
happy coding!
|
|
|
|
|
Suj_78 wrote: RandomNumber = new Random();
Put that line outside the loop.
When you create a new Random number generator it is seeded against the current time. If the loop is very short there is no time for the clock to update, so it gets reseeded against the same time as the last iteration, therefore producing the same number again.
|
|
|
|
|
Thanks Colin.
happy coding!
|
|
|
|
|
I'm developing some desktop applications in Visual Studio 2005 and wonder if there are any tools to change colors(gradient) and shapes on controls in a easy way?
|
|
|
|
|
Yes. The user simply changes them in his "Display settings". In case you have never seen this you can find it in the "Display" Icon in "Control Panel"
led mike
|
|
|
|
|
If you want to work with .NET 3.0, then you can easily change gradients and drawing styles of standard windows controls using WPF.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Hello...
I make a new control and put it in a new form. How can I detect, if the control is loaded in Visual Studio Designer or directly in Runtime ?
Because if the control is loaded in designer, it shows some stranges behaviour. That's why, I want to cancel it, if the control is in designer.
Thx...
|
|
|
|
|
Hi there
Assuming you're talking about WinForms here: There is a DesignMode property, which can be evaluated. Do note, however, that you cannot use the property in the designer - this is why I usually use OnLoad . Here's a sample, which also plays nicely with controls you're going to extend:
///
/// Inits the base class and registers event listeners.
///
/// <param name="e" />
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (!DesignMode)
{
//your internal initialization logic
InitControlInternal();
//the template method below - for extending classes
InitControl();
initControlCompleted = true;
}
}
///
/// An empty template method which is being invoked after the
/// control has been loaded during <see cref="OnLoad">.
///
/// <remarks>The base class does not invoke this method if
/// the control is in design mode.
protected virtual void InitControl()
{
//this method is supposed to be overridden. Initialization of
//the base class itself happens in InitControlInternal
}
HTH,
Philipp
|
|
|
|
|
Hai
I have a mulit line textbox on each time I enter data into it from another text box it should enter data in a new line in the mulitiline textbox
Thanks & Regards
|
|
|
|
|
If the length of the string in the multiline textbox is greater than 0, append the Environment.NewLine and the value from the other textbox.
|
|
|
|
|
Hai
I have two forms opened in my mdiparent form I want to pass the value from textbox of 1st form to textbox of the 2nd form I cannot create a new instance of the 2nd form since I want to send to the same opened instance, I tried by changing the property to public but cannot be acessed with out creating a new instace pls help me to pass the values to the same opened instance of the form
Thanks & Regards
|
|
|
|
|
declare a variable as static ..........if this doenst works take a class declare static variables in it assing the values to the stat variable while u r in first form then use them in next form.......................please dont mind ...make u r question clear
regards
sindhu tiwari
its me sid
|
|
|
|
|
sindhutiwari wrote: declare a variable as static
What if there is more than one instance of the form class?
sindhutiwari wrote: make u r question clear
What about your answer. For the most part it was a clear as mud.
|
|
|
|
|
|
Don't try passing values between forms. A neater architectural approach, is to abstract the data model from the actual visual representation of the value. One way to do this is to implement something called the Model View Controller[^] pattern.
|
|
|
|
|
have a public variable in mdi window,
once you open the child forms, in the form load assign the control to mdi public variables
instead of access the form2 text box , access the mdi variable.
regards
Elayaraja.S
|
|
|
|
|
I am using C#, GDI+.
I have drawn the line (using DrawLine()) from point(10,10) to point(20,20). The center point of the line is (15,15). Suppose i Rotate At(10,10) the line for 30 degrees.
How to calculate the center point after rotating?
|
|
|
|
|
For a line from (a_x,a_y) to (b_x,b_y) this is very simple.
The center is always ( (a_x+b_x)/2, (a_y+b_y)/2 )
So either you have the new endpoints and use this formula or
you apply your transformation to the old centerpoint (yes you can do this in .net)
|
|
|
|
|
Hello to all,
My name is Manoj kumar. I am facing a problem related with Tcp. I want to bring .txt file from remote computer using Tcp server. On remote maching a program is running which uses Tcp client to transfer the .txt file. The client port is 5003 and the ip address is 192.168.1.12.
|
|
|
|
|
This seems straightforward:
Use a tcplistener to check for incomming connections.
After accepting a connection just send the content of the .txt file using ASCII or Unicode - encoding (there are Encoders in System.Text - namespace) over the accepted socket and close the connection.
On the client just use a TcpClient to connect to the server and use the class-methods to read all the stream, decode it with the same encoder you used (ASCII/Unicode/whatever) and you've got it.
|
|
|
|
|
Hi there,
I've been having a problem for days regarding the following bit of code. Basically, I have a web service which looks like this...
<br />
[WebMethod]<br />
public DataSet TestMethod1(string input)<br />
{<br />
DataSet ds;<br />
ds = new DataSet();<br />
ds.Tables.Add("HIHI");<br />
return ds; <br />
}<br />
...and some code that calls it which looks like this
<br />
HttpWebRequest httpRequest;<br />
HttpWebResponse httpResponse;<br />
byte[] inputs=null;<br />
UTF8Encoding encoding = new UTF8Encoding();; <br />
for(int i=0;i<3;i++)<br />
{ <br />
httpRequest = (HttpWebRequest)HttpWebRequest.Create("http://localhost/StaticSer/Service1.asmx/TestMethod1");<br />
httpRequest.Method = "POST";<br />
httpRequest.Credentials = new NetworkCredential("", "", "");<br />
httpRequest.KeepAlive = true;<br />
httpRequest.AllowWriteStreamBuffering = true;<br />
httpRequest.AllowAutoRedirect = true;<br />
httpRequest.ContentType = "application/x-www-form-urlencoded";<br />
<br />
if(i==0)<br />
inputs = encoding.GetBytes(@"INPUT=someInput_1");<br />
<br />
if(i==1)<br />
inputs = encoding.GetBytes(@"INPUT=someInput_2");<br />
<br />
if(i==2)<br />
inputs = encoding.GetBytes(@"INPUT=someInput_3");<br />
<br />
httpRequest.ContentLength = inputs.Length;<br />
httpRequest.GetRequestStream().Write(inputs, 0, inputs.Length);<br />
httpResponse = (HttpWebResponse)httpRequest.GetResponse();<br />
<br />
httpResponse.Close();<br />
httpRequest=null;<br />
httpResponse = null; <br />
}<br />
The problem is that it runs perfectly fine the first time in the loop, but times out on httpRequest.GetRequestStream().Write(inputs, 0, inputs.Length); thereafter.
I am using vs2003 at the moment, and the strange thing is that the code above seem to work perfectly fine in vs2005.
Another thing I've discovered is that the above code works if the web service takes no inputs, e.g.
public DataSet TestMethod1() and
....<br />
inputs = encoding.GetBytes("");<br />
....
I'm guessing it might have something to do with httpRequest not releasing resources after the first run, but am at a lost to know how to be sure. I'd appreciate it if someone could give me some pointers. Thanks
|
|
|
|
|
You have to close the stream from your request:
httpRequest.GetRequestStream().Close();
In fact, I would recommend the following code:
<code>
using (Stream requestStream = httpRequest.GetRequestStream())
{
requestStream.Write(inputs, 0, inputs.Length);
}</code>
-----
You seem eager to impose your preference of preventing others from imposing their preferences on others. -- Red Stateler, Master of Circular Reasoning and other fallacies
If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
God is the only being who, to rule, does not need to exist. -- Charles Baudelaire
|
|
|
|
|
Hi
I have developed a Client-Server application using socket.When Client side application executes on another system an error occures(Only one usage of each socket address (protocol/network address/port) is normally permitted).But already a TcpListener application has been executed on that system .I need both application to be executed simultaneously.
How to solve this problem???Plz help me.......
Thanks
Smithakrishnan
|
|
|
|