|
Thank you so much! It really helps and I am done with the required changes.. GREAT!
|
|
|
|
|
You're welcome
I are Troll
|
|
|
|
|
I need HELP on how do i or how can i get the time and date of previous startup of C# Windows application and use that time and compare with current system time and date with an if else
|
|
|
|
|
Write the start time to a log record (file or table) and compare the last 2 entires.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I would use the registry for such that. Choose one key (say HKCU/Software/CompanyName/ProductName/LastRun), read whatever it contains, then update it by storing the current time, preferably using a standard format such as DateTime.Now.ToString("s")
|
|
|
|
|
I use an XML file in the application data directory to store stuff like that.
|
|
|
|
|
Hi,
I am using webclient while uploading large file(135MB) using windows application. My Code works but when it reaches to stream.close() it showing following error
Error:-
The CLR has been unable to transition from COM context 0x1ff030 to
COM context 0x1ff1a0 for 60 seconds. The thread that owns the destination
context/apartment is most likely either doing a non pumping wait or processing
a very long running operation without pumping Windows messages. This situation
generally has a negative performance impact and may even lead to the application
becoming non responsive or memory usage accumulating continually over time.
To avoid this problem, all single threaded apartment (STA) threads should use
pumping wait primitives (such as CoWaitForMultipleHandles) and routinely
pump messages during long running operations.
So because of that my file is not uploaded. what is the problem?
My Code is:-
WebClient client = new WebClient();
Stream stream = client.OpenWrite(remoteFilename, "PUT");
// The buffer size is set to 2kb
const int buffLength = 2048;
byte[] buff = new byte[buffLength];
int contentLen;
// Opens a file stream (System.IO.FileStream) to read the file
// to be uploaded
FileStream fs = fileInf.OpenRead();
int doneSoFar = 0;
// Read from the file stream 2kb at a time
contentLen = fs.Read(buff, 0, buffLength);
//added for accurate progress
doneSoFar += contentLen;
setItemStatus("Uploading");
while (contentLen != 0)
{
setItemProgress(doneSoFar, fileInf.Length);
// Write Content from the file stream to the FTP Upload Stream
stream.Write(buff, 0, contentLen);
contentLen = fs.Read(buff, 0, buffLength);
doneSoFar += contentLen;
}
// Close the file stream and the Request Stream
stream.Close();
fs.Close();
for Small file size it works fine.
Thanks
sjs
|
|
|
|
|
Hi there
I have a variable that its type is list of structure.
My structure is like below :
public struct Order
{
public string name;
public int amount;
public double price;
public List<string> toppings;
}
And my variable is like below :
public static List<Order> myorder = new List<Order>();
I have SQL database for my program. and I need store myorder variable to database.
If you know appropriate solution for it, please tell me.
Best Regards,
Reza Shojaee
|
|
|
|
|
You'd use an INSERT [^] statement to write the contents of your structure to the appropriate table.
Is there already a table called "Orders" (or something similar) in your database?
I are Troll
|
|
|
|
|
hi i have a form name frmDataEntry with textboxCustID and textboxCustName and lookup form name frmCustAssist with texboxFilter, button Filter and datagridview then when i double click textboxCustID then frmCustAssist will show i have to look if customer already exist or not then if already exist i hav to get the value of row index ..then the custID and custName of that value selected will be fill in the formDataEntry in textboxCustID and textboxCustName how do code that that plz help
my code is here..
<br />
in a frmCustAssist<br />
<br />
private void button1_Click(object sender, EventArgs e)<br />
{<br />
bindingSource1.Filter = "LASTNAME like '%" + textBox1.Text + "%'";<br />
bindingSource1.Sort = "LASTNAME";<br />
selected row value .. somwthing like that<br />
<br />
}<br />
in a frmDataEntry
selected value custID =textboxCustID
selected value custname = textboxCustName
|
|
|
|
|
Hi
You shall insert a column to your datagridview with type of button(for example).
you can set caption of button as "Select".
So use the CellContentClick event and in the body of this event for getting data of row that user clicked on the button of same row use below code :
dataGridView1.Rows[e.RowIndex].Cells[i].Value.ToString();
Best Regards,
Reza Shojaee
|
|
|
|
|
any one knows how to pass an object by value instead of reference in C#?
|
|
|
|
|
Step 1) Ensure it's a value.
Step 2) Pass it.
|
|
|
|
|
Hi,
that is not possible.
Not sure why you think you want that. Maybe what you need is a clone, i.e. a second object that is an exact copy of the original, so changing it would not change the original. I very seldom need that though. I suggest you explain the situation.
|
|
|
|
|
thanx, i just wanted to know whether it is possible or not , cloning means before sending we create a copy of the object and send it to the method. hmmm.. thanx.
|
|
|
|
|
|
prasadbuddhika wrote: cloning means before sending we create a copy of the object and send it to the method.
Which is also passed by reference...
|
|
|
|
|
|
But most of those values are references.
|
|
|
|
|
Everything that is passed is a value in the truest sense. However that value is (most) often a reference to the object rather than the 'value' itself.
The only way to do what the op wants is to create a new object (therefore a new reference) and copy the values the object holds. Where the object's values are also references, new copies of those also need to be created. This needs to be done recursively until all object references have been recreated.
This is known as deep cloning and, as you can see, can be quite an involved and complex task which is why there is no built in Clone method in the framework. The closest we have is ICloneable which has (of course as it's an interface) to be implemented by the creator of the class.
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Assume I write a class called Customer. On it are CustomerKey and CustomerName properties. You set the key to the customer's PK and call the SaveChanges method.
The SaveChanges method first calls a private bool method called Validate. If the CustomerName property is not completed, how would you deal with it? Throw an exception? Maybe set an ErrorMessage property?
Bear in mind that this class may never actually be bound to any UI. It may only ever be called from another non-visual class.
Everything makes sense in someone's mind
|
|
|
|
|
What we do is use an Errors collection, and add the fields that failed validation to the collection. The Validate method then returns false. The calling class looks something like
if (customer.Validate())
{
}
else
{
foreach (Error fieldError in customer.Errors)
{
}
}
Don't blame me. I voted for Chuck Norris.
|
|
|
|
|
That's an excellent idea. Thanks!
Everything makes sense in someone's mind
|
|
|
|
|
Throwing exception would be fair enough.
Best wishes,
Navaneeth
|
|
|
|
|
i want to filter something like string type in my textbox but my code is not working..how do i fix this
<br />
private void button1_Click(object sender, EventArgs e)<br />
{<br />
bindingSource1.Filter = "LASTNAME = LIKE% + textBox1.Text";<br />
bindingSource1.Sort = "LASTNAME ASC";<br />
}<br />
<br />
<br />
|
|
|
|