|
My suggestion is, create 2 image list, one with 32x32 size and other with 16x16
|
|
|
|
|
Thank you very much! I was just making sure this was the "proper" way of doing things!
|
|
|
|
|
hi,
plz tell me How to insert the values in to two database tables in C#.
Thanks.
Himanshu
|
|
|
|
|
himanshu_roy81 wrote: How to insert the values in to two database tables in C#.
Technically, you do this with 2 SQL commands, not C#, but I get what you mean. Basically, you need to create two insert statements (make sure you use parameterized queries), and then you run them both in order - you can use one command object for this (use the ExecuteNonQuery method to perform it).
I haven't specified which of the command classes to use because you haven't specified which database you're hitting, i.e. if it's SQL Server, you'd use SqlCommand. (If both of the inserts have to be performed in one transaction, you'd wrap them up in a transaction).
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
You need to decide / specify which technology you want to use.
Check out the following:
ADO.NET
LINQ (to SQL or to Entities)
TableAdapters.
There are other, 3rd party ways to do this (e.g. Nhibernate). Which technology you choose is dependant upon your circumstances.
|
|
|
|
|
"INSERT INTO table1 ... <big>;</big> INSERT INTO table2 ... "
|
|
|
|
|
hello
I am having datagridview with columns
Description area rate and value.
All the columns are datagridview textbox columns.
the description column when clikced where we can enter the description
and when the columns area,rate and value are double clikced then the
page must redirect to another page.
I tried this by the event CellDoubleClick but i can't get what i required
Plz, help me in doing this.
|
|
|
|
|
Anjani Poornima wrote: I tried this by the event CellDoubleClick but i can't get what i required
What does this mean?
What do you get?
What have you tried?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
hello,
I wrote the code for redirecting the page in celldoubleclick event.
It make me redirect the page when the column is doubleclicked.
But what i need is only when the column 'area' is doubleclicked it must
redirect the page.
Here i have to check the condition only when the column area is double
clicked it must redirect the page.
How to do this.What event i have to use.
Plz, help me in doing this.
|
|
|
|
|
There are two DoubleClick events for a cell CellDoubleClick , which you have already used, and CellContentDoubleClick . The DataGridView is very fussy about exactly where you click. If you double-click on the displayed value but are only handling the CellDoubleClick event, nothing happens. Conversely, if you double-click in the cell, but not on the displayed value and you are only handling the CellContentDoubleClick event, nothing happens then either.
Set up a handler method for both:
private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
{
MessageBox.Show("Content DoubleClick");
}
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
MessageBox.Show("Cell DoubleClick");
}
and experiment with the placement of your double-clicks.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
What is your problem excactly?
If you don't know how to redirect, look here Response.Redirect()[^]
Anjani Poornima wrote: I tried this by the event CellDoubleClick but i can't get what i required
Did you get any good data from the event as in what cell contained or from witch row was it?
|
|
|
|
|
suppose i have one mdi form and two mdi child form. suppose i have save method in both the mdi child form and i just want to call the save method of active mdi child form from mdi parent form.please help with sample code.
thanks in advance
tbhattacharjee
|
|
|
|
|
No sample code, just a few bits of advice. If all of your MDI children are the same type, then you can call something like this.MdiChildren.Cast<YourChildTypeHere>() to convert the list of MDI children to a list of your forms. Then just iterate over the collection, calling the save method on each element.
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
My C# web application is trying to read the Private Key of the our own digital certificate installed on Windows 2008 Server, when it needs to decrypt the data received from the web request.
Following is the code:
X509Certificate2 cert = GetCert(thumbPrintOfPrivKey, StoreName.My, StoreLocation.CurrentUser);
try
{
string privateKey = cert.PrivateKey.ToXmlString(true);
log.Info("Retrieved Private Key....");
rsacsp.FromXmlString(privateKey);
}
catch(Exception e)
{
string msg = "Unable to Read the Private Key: ";
log.Error(msg + e.Message);
throw new Exception(msg, e);
}
And following line of above-mentioned code throws an error.
string privateKey = cert.PrivateKey.ToXmlString(true);
The error which I get is: - "The system cannot find the file specified."
And following is the stack Trace:
at System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer)
at System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType, CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle)
at System.Security.Cryptography.RSACryptoServiceProvider.GetKeyPair()
at System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize, CspParameters parameters, Boolean useDefaultKeySize)
at System.Security.Cryptography.RSACryptoServiceProvider..ctor(CspParameters parameters)
at System.Security.Cryptography.X509Certificates.X509Certificate2.get_PrivateKey()
at SSO.SSOUtility.ProcessData(String decodedSig, String decodedToken, String combined) in
When I checked my Application Event Logs to see what exactly is happening, the event log showed that the "CertificateServicesClient" has stopped. And I noticed that it gets started automatically when I logon to the server.
Can anybody please help me in finding the reason as to why this service(?) stops and starts automatically, and how can we restart it immediately the moment it stops?
Thanks in advance.
-----
Ajay Jadhav
http://www.divinet.co.in
|
|
|
|
|
|
Yes, it is.
-----
Ajay Jadhav
http://www.divinet.co.in
|
|
|
|
|
I have this method that accepts a ZipFile as a parameter and does some work etc, but after looping within a while loop, the parameter (ZipFile) is disposed... I will show a quick example instead of the original code because it would be unnecessarily complex.
private byte[] GetImage(ZipFile originalZipFile, string pass)
{
while(true)
{
ZipFile zipFile = originalZipFile
foreach(ZipEntry zEntry in zipFile)
{
if(true)
return new byte[];
}
}
}
I have attempted to keep the example simple enough.. So, zipFile is closed and set to null within the while loop, even before the return (else an exception occurs, since the ZipFile is using a FileStream which is later needed). However, originalZipFile is for some reason being disposed without any calling directly accessing it (that is why originalZipFile is copied into zipFile)
What can I do in order to keep originalZipFile from being disposed? Or what am I doing wrong? Thanks!
(As far as I am concerned, ZipFile is a class not a struct, so there shouldn't be any problems, with multiple references to the same 'object' on the stack).
|
|
|
|
|
If ZipFile is a class and not a struct, then you are not making a copy of originalZipFile when you assign it to zipFile, only a copy of the reference. So anything you do to zipFile is done to originalZipFile since they both reference the same object. If you intended to make a copy of originalZipFile, you will have to make and use a method that will create the copy.
|
|
|
|
|
Hi,
there is no Dispose() and no using construct in what you have shown, so nothing is getting disposed of as far as we can see.
If things go wrong, chances are you didn't understand how something works, hence it is quite possible that by simplifying the code to show it here, you also have hidden the problem.
Show exact code, omitting only the parts that are really irrelevant; but do show everything that happens to originalZipFile and any copies thereof.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
First of all I would like to thank you for taking the time to reply You really seem like you want to help So, I totally agree with you that by simplifying the code I might also be hiding the problem.
The program functions as follows. At every specified interval, the application extracts an image from a ZIP file according to "liked shoots" since this is based on a group of photographers each having their own shoots submitting, and so on...
The code in demand is a follows:
private byte[] GetShootImage(ZipFile originalZipFile, string pass, string shootName)
{
while (fm.LikedShoots.Count > 0)
{
ZipFile shootZipFile = originalZipFile;
ZipEntry zipEntry = shootZipFile.GetEntry(fm.LikedShoots[0]);
if (zipEntry != null)
{
TempSaveStream(shootZipFile.GetInputStream(zipEntry), zipEntry.Size, true);
zipEntry = null;
shootZipFile.Close();
shootZipFile = null;
shootZipFile = new ZipFile("C:\\WINDOWS\\Temp\\TpTmp\\temp.tmp");
shootZipFile.Password = pass;
foreach (ZipEntry entry in shootZipFile)
{
if (!fm.ImageGenerated(fm.LikedShoots[0] + "\\" + entry.Name))
{
fm.GeneratedPhotos.Add(fm.LikedShoots[0] + "\\" + entry.Name);
buffer = TempSaveStream(shootZipFile.GetInputStream(entry), entry.Size, false);
shootZipFile.Close();
shootZipFile = null;
return buffer;
}
}
}
fm.ExhaustedShoots.Add(fm.LikedShoots[0]);
fm.LikedShoots.RemoveAt(0);
}
}
On the 2nd loop, the marked line of code throws an ObjectDisposedException within the originalZipFile object. However, as you can see, originalZipFile is not set to null or anything. Can the GC have collected it or what?
In the mean, I would like to thank you so much for taking the time to reply.
|
|
|
|
|
Hi,
I haven't grasped the structure of your code yet; anyway this code too could use some cleaning up:
1. parameter shootName isn't used.
2. several xxx=null; don't make any sense.
3. as TempSaveStream() causes problems, one should look at its code.
Please make sure you have proper error/exception handling, as explained in our other conversation.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I'm posting just to let you know of a few 'updates'. I haven't changed the code yet, but I will soon enough, and I'll inform you then.
At the moment:
1. 'shootName' is used but not in that code extract. It's in the same method, but it's set in a if...else situation, which is irrelevant
2. I'm not sure if this is my misconception or anything, but I had rather thought that if an object is set to null, this makes GC more likely/quickly to occur on that object, to release the resources occupied by it? If this is my mistake, than I'm glad to know
3. I'll check TempSaveStream() again to ensure that it's not causing the problem.
Furthermore, I WILL check the exception handling, due to the embarrassing exception handling I've implemented in the other conversation we've had
Besides, I will check certain properties in the ZipFile class, since, for instance, there is a particular property that once the child's finished, it also closes the parent zip. So it may be something along those lines
Thanks for taking the time I'll keep you informed
|
|
|
|
|
suppose i have two table table1 & table2. now how can i sync the data of two table of sql server using microsoft sync frame work or using any other class.
tbhattacharjee
|
|
|
|
|
You can use "Instead Of" or "After" triggers on those tables for Insert, Update and Delete actions.
For example:
<br />
USE YourDatabase<br />
<br />
CREATE TRIGGER Table1_AfterDelete <br />
ON Table1 AFTER DELETE<br />
AS<br />
DELETE Table2 WHERE Table2.Id IN (SELECT Id FROM DELETED)<br />
GO<br />
<br />
CREATE TRIGGER Table1_AfterInsert <br />
ON Table1 AFTER INSERT<br />
AS<br />
INSERT INTO Table2 SELECT * FROM INSERTED<br />
GO<br />
<br />
CREATE TRIGGER Table1_AfterUpdate <br />
ON Table1 AFTER UPDATE<br />
AS<br />
UPDATE Table2<br />
SET Table2.FirstName=Table1.FirstName, Table2.LastName=Table1.LastName<br />
FROM Table2 JOIN Table1 ON Table2.Id=Table1.Id<br />
GO
|
|
|
|
|
While stonehearts answer is technically correct, I would question your data structure if you are storing the same data in 2 tables. I suggest you do some research into normalising your database (said with absolutely no knowledge of your data structure).
Besides triggers are EVIL and should be avoided unless they are essential.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|