|
hi all,
i am working on a basic challenege for my course in C#, i have got to the point where i need the loop to do its actions until 2 statements become true but my program runs through the loop once and one statement becomes true and other false and then it jumps out of loop so i need to know what i have done wrong with the code or any advice please?
int z = 2;
if (remaindernum != 0 & remainderden != 0)
{
while (z <= totala)
{
while (remaindernum != 0 & remainderden != 0)
{
remaindernum = (newfraction % z);
remainderden = (totala % z);
z += 1;
}
}
}
just to clarify pretending my first line of code is 0,
it runs through fine till line 15 then goes back into loop at line 7 but then jumps down to line 16 and sticks in neverending loop
|
|
|
|
|
I suspect you want OR rather than AND. You may also want to use the Logical operators rather than the Bitwise ones.
|
|
|
|
|
basically its a loop to simplify a fraction , so i need that loop to keep running until both statements are true?
|
|
|
|
|
also should i be using a do statement for this kind of thing?
|
|
|
|
|
|
You are using the wrong operator, it should be the double ampersand thus:
if (remaindernum != 0 && remainderden != 0)
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hello,
I have a table consisting of following columns and data
Msg_count Latitude Longitude Utc_Time
16 56.6650356667 12.8772211667 142640
24 56.6650415 12.8772395 142640.25
35 56.6650475 12.8772581667 142640.5
26 56.665053 12.8772778333 142640.75
23 56.6650593333 12.8772976667 142641
26 56.6650656667 12.8773183333 142641.25
25 56.665072 12.8773388333 142641.5
15 56.6650785 12.8773598333 142641.75
i need to find out sum of messages transmitted every second.
For eg. when i group (142640, 142640.25, 142640.5, 142640.75) it makes 1 sec and total number of messages sent during this interval are
16+24+35+26=101
I don't know how can do this.
I am using PostgreSQL and C#.net
Does anyone have suggestion
Regards..
Tasha
|
|
|
|
|
This isn't really a C# question, it would have been better to post in the SQL forum, but:
One solution (the one I'd use is
- round the
Utc_time to the second, the rounding function you need depends whether you want to round up, down or to the nearest value - Group by the value from step 0, getting the count
|
|
|
|
|
I am doing hospital project(desktop application)
I am using SAP crytal reports for prescription & certificates.
Here is my code:
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(@"D:\Paranjpe_Hospital\Paranjpe_Hospital\CrtlRpt_OPD_pres_gen.rpt");
cryRpt.SetDataSource(ds.Tables[0]); //check it by writing only ds
Print_All_Certificates opd_pres = new Print_All_Certificates();
opd_pres.crystalReportViewer_all_certificates.Refresh();
opd_pres.crystalReportViewer_all_certificates.DataBindings.Clear(); //check it
opd_pres.crystalReportViewer_all_certificates.ReportSource = cryRpt;
opd_pres.Show();
Here problem is that ,when I printing prescription,it is always showing 1st prescription.
So,everytime I have to click on > ("Go to last page") in cryatal report viewer then it shows current prescription & then I am printing it.
How can I print current prescription without clicking on > ("Go to last page") in cryatal report viewer?
Please tell me solution of this problem.
|
|
|
|
|
Did you fill that table with just the one record you want to print or did you fill it with ALL the perscriptions in the table? Hint, hint.
|
|
|
|
|
Yes. I filled that table with just the one record I want to print.
In other words I am saving one prescription as one record in a table.
|
|
|
|
|
Well, if that was the case, then you'd get your correct record. Either you're filling that datatable with all the records or your retrieving the wrong record in your SQL.
|
|
|
|
|
hello
Anybody ever capture HttpRequest from Fiddler or WinpCap, then reconstruct a HttpRequest object?
Does anybody knows how to do this?
Thanks
dev
|
|
|
|
|
what's the problem with that???
I don't quite see the so I just pasted below some code to create a webrequest...
var wr = (HttpWebRequest)WebRequest.Create(uri);
SetHeader(wr, "GET", new Dictionary<tring,string> { { "Content-Type", "x-text" }, ..});
if (stream != null && stream.Length > 0)
using(var ws = wr.GetRequestStream())
Copy(stream, ws, length);
...
public static void SetHeader(HttpWebRequest req, string method, Dictionary<string, string> headers)
{
req.Method = method;
foreach (var kv in headers)
{
var k = kv.Key;
var v = kv.Value;
switch (k)
{
case "User-Agent":
req.UserAgent = v;
break;
case "Host":
break;
case "Accept":
req.Accept = v;
break;
case "Proxy-Connection":
case "Connection":
req.KeepAlive = (v ?? "").ToLower() == "keep-alive";
break;
case "Referer":
req.Referer = v;
break;
case "Content-Length":
req.ContentLength = reqSrc.ContentLength;
break;
case "Content-Type":
req.ContentType = v;
break;
case "If-Modified-Since":
req.IfModifiedSince = DateTime.Parse(v);
break;
default:
req.Headers.Add(k, v);
break;
}
}
static void Copy(Stream src, Stream dst, int len)
{
var buff = new byte[1 << 12];
int nread = 0;
int toRead = buff.Length > len ? len : buff.Length;
while ((nread = src.Read(buff, 0, toRead)) > 0 && len > 0)
{
dst.Write(buff, 0, nread);
len -= nread;
toRead = buff.Length > len ? len : buff.Length;
}
}
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
no. i know and done too many times constructing HttpRequest object from a url
but this time, i have a text string captured from say Fiddler/WinPcap - I don't want to parse url, extract query string/cookies anually myself so my question really is - any free code where i can instantiate a HttpRequest by passing to it Http request in form of a string captured by WinPcap or Fiddler.
dev
|
|
|
|
|
hi guys..can someone help me how to send a message on smart bro using c#? how to do this? when someone send me a text, the smart bro will automatically reply to the text.. if the text is "citutu" the reply is "ok" and if is not, the reply is "wrong code" what should i do? please help me..any bits of help would be a great step ahead on my research.. thank you for reading this..
|
|
|
|
|
1. Learn basics of C#
2. Learn basics of network programming.
3. Learn the protocol that defines "smart bro"
4. Put 1/2/3 together to create code that does what you want.
5. Test 4 and fix problems.
I would suspect that you might also need to learn about windows services. But that depends on what you mean by "automatically".
|
|
|
|
|
thank you for the reply..actually, i already have some codes from the internet on how to send and receive messages..however, the smart bro show 3 ports, COM3, 4, and 5.. i dont know why..i tried to use all the ports but i havnt successfully connected the smartbro to my c#..this is really my actual problem, how to connect smart bro to my c#. i already know about serialport class and gsmcomm..but i still dont know why cant i access my smart bro...huhu
|
|
|
|
|
And you know what protocol is expected on the serial port to talk to that device?
Do you have other software which does talk to it? Or in other words how do you know that the device is even interacting at the hardware/driver level?
|
|
|
|
|
i dont know either..thanks for the reply..i think i need more time and research for this..i have tried using hyper terminal.but it doesnt work.. i cant interface my smart bro using hyper terminal..i dont know whats the problem but i have read articles that interfacing smart bro is possible..thanks again..
|
|
|
|
|
I need to create a server client system and though I have created several libraries for tcp/ip communications (sockets, named pipes) I want to buy a profecional component that can handle packages loss, message compression and low quality networking. I have see that remobjects are a nice implementation but I cannot find any reviews for the product. Have you ever used remobjects for a project or any other simular component for C#?
thank you
|
|
|
|
|
Nowadays all the hype goes to WCF (excellent if one overlook the horrible configuration stage)
And there is a great open source alternative: http://www.servicestack.net/[^]
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Thank you for your answer,
I haven't thought WCF as an alternative and I searched for it but I read that it's not good in networking oop but It's better for SOA. The WCF developer has a huge overhead of interfaces and classes just to make it transmit some objects and the documentation of TCP/IP WCF is not very good.
I'll check the opensource alternative but I most probably use RemObjects. My main concern is that I cannot find any ppl using them and I worry if they worth the money they costs.
|
|
|
|
|
I'm on holiday typing from my phone now...
isn't the "ip" (from tcp/ip) handling package loss for you?
unless you want to use UDP?
I think there is a code project article about wcf over UDP...
at any rate this problem has perfectly good and free solution, I don't see why you would have to pay anything for that...
wcf use soap messages (I.e. Extremely verbose XML) over http
so it heavy..
but this is just the default setting, you can use TCP connection and binary formatter in your configuration! And even compression too! Ni service change!!
but apparently servicestack is even more compact
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Can anyone pls help me with the same problem.
I have Stored the User's profile Image's filename in the database column Image.
And the image to a folder named UserImage.
Can anyone pls help me with the code to display the image of corresponding user to the repeater.
I tried the above code but not working.
Pls help me.
Its urgent.
thanks in advance.
|
|
|
|