|
Roberto Collina wrote: Is this a correct way of storing multiple references, or is there a better method you can shed some light on (performance-wise, or just coding-wise)? Is this going to produce GC issues?
A reference just points (or refers) to the actual object. If you store an object reference on two different lists all that is happening is that you now have two places that point (refer) to the same actual object.
It won't cause GC problems. The garbage collector will only remove an object when nothing refers to it any more.
In terms of performance, if you need a list sorted by Z-Order and a list of visible only objects for different purposes then it will probably improve performance. You just need to ensure that the lists are kept up to date an in sync with each other.
Roberto Collina wrote: I have read about WeakReferences in a reply over these forums but I'm not sure about their usage in this context.
A weak reference is a reference to an object that CAN be garbage collected. In other words you cannot rely on the reference, it may suddenly become null without you realising.
Obviously, if you have something that is a weak reference and you assign it to something then it becomes a stong reference and the garbage collector won't touch it.
Weak references are rarely needed and from the information you've given I don't see why you would need them.
|
|
|
|
|
|
Set the DataSource of your ComboBox to be the clients DataTable object contained within your DataSet instead of the DataSet itself.
Omit the table name prefix when setting the DisplayMember and ValueMember properties of your ComboBox.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
I would like to be able to detect changes in files so that when A file/folder is monitored whilst the program is running it fires an event, or it is detected on start-up if the changes happen when the program is not running.
Does anyone have any general ideas on how to go about doing this such as APIs that would help me out rather than coding it for me, (of course that would be nice :P)
Thanks.
|
|
|
|
|
|
this is the sequence of filesystem(subject) question
I GOT ONE PROBLEM AGAIN
HERE IT IS TAKING THE FILE NAME WITH EXTENSION WHAT I HAVE TO DO TO IGNORE EXTENSION
REGARDS
SUNILWISE
|
|
|
|
|
sunilwise wrote: this is the sequence of filesystem(subject) question
I GOT ONE PROBLEM AGAIN
HERE IT IS TAKING THE FILE NAME WITH EXTENSION WHAT I HAVE TO DO TO IGNORE EXTENSION
This really doesn't make much sense. And SHOUTING doesn't help either.
If you want to ignore the extension on a filename then ignore everything after the last dot. If that does not answer your questions then please clarify it.
|
|
|
|
|
Colin Angus Mackay wrote: If you want to ignore the extension on a filename then ignore everything after the last dot. If that does not answer your questions then please clarify it.
exactly can u plz send me some code how to ignore the extension after the dot
regards
sunilwise
|
|
|
|
|
sunilwise wrote: can u plz send me some code how to ignore the extension after the dot
First, please write properly - I have no patience for people who contract word such as "you" in to "u" and "please" in to "plz". The English language has a perfectly acceptable mechanism for contracting words by the use of an apostrophe to stand in for missing letters. If you absolutely must use abbreviations please use ones that are understandable to all. Not everyone on this forum speaks English as their first language. They will have difficulty reading badly written text.
In answer to your question look into the string class and look for things to get you the LastIndexOf[^] in order to tell you where the dot is and Substring[^] in order to get a new string without the extension.
Alternatively, classes such as FileInfo and Path also have methods for dealing with bits of file names.
|
|
|
|
|
Colin Angus Mackay wrote: Not everyone on this forum speaks English as their first language. They will have difficulty reading badly written text.
Good point.
"If you divide your text into sentences, it might be possible to understand what you are trying to say." - Guffa
|
|
|
|
|
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
FileInfo TheFile = new FileInfo(MapPath(".") + "\\" + txtOldFile.Text);
if (TheFile.Exists)
{
File.Move(MapPath(".") + "\\" + txtOldFile.Text,MapPath(".") + "\\" + txtNewFile.Text);
}
the above is my code for renaming the file in my application its working fine, but what i want is i want to keep my original file as it is and create another file with same content in it with different name
valid suggestions are appriciated
thanks in advance
regards
sunilwise
|
|
|
|
|
File.Copy
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
thanks for reply its working
|
|
|
|
|
Hello,
I am using MySql as my database. I can fill individual tables, however when I query to select from 2 different tables and do an add watch on the dataset the count for those 2 tables is 0.
Everything runs without errors. However, when I check count property for the table in the add watch it gives an zero.
However, if I write the query like this: "SELECT * FROM Beverage"
and fill using this da.Fill(DS.Beverage); Then the count display the correct number of rows.
Can anyone explain this?
Many thanks,
My code for filling
try<br />
{<br />
this.OpenConnection();<br />
<br />
RestaurantDataSet ds = new RestaurantDataSet();<br />
MySqlDataAdapter da = new MySqlDataAdapter();<br />
MySqlCommand cmd = new MySqlCommand();<br />
<br />
cmd.Connection = cnn;<br />
cmd.CommandType = CommandType.Text;<br />
cmd.CommandText = "SELECT maincourse.MainCourseID, beverage.BeverageID FROM maincourse, beverage";<br />
<br />
da.SelectCommand = cmd;<br />
da.Fill(ds);<br />
<br />
return ds; <br />
}<br />
catch (Exception ex)<br />
{<br />
Console.WriteLine(ex.Message);<br />
return null;<br />
}
|
|
|
|
|
steve_rm wrote: cmd.Connection = cnn;
Where is cnn ? Is it a global? I am assuming the connection is opened and cnn is set when you execute this.OpenConnection();
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hello,
Problem solved. The query was pulling 2 tables out of the database and which will create a new data table.
Steve
|
|
|
|
|
Cool deal that you got it solved
"The early bird may get the worm, but the second mouse gets the cheese" - anonymous, found in Uncle John's Bathroom Reader
|
|
|
|
|
Hi,
My aim is to print the windows form dynamically .
The code which i have implemented for creating a bmp.file of the form is
/*
Bitmap bit = new Bitmap(this.Width, this.Height);
this.DrawToBitmap(bit, new Rectangle(0, 0, this.Width, this.Height));
bit.Save(@"c:\new.bmp", System.Drawing.Imaging.ImageFormat.Bmp); */
So the image is getting stored now i want to print it on a single button click if possible before that a preview screen.. if anyone knows how to complete this task or any ideas please let me know
regards
sindhu tiwari
Alwasys Innovative
|
|
|
|
|
Try this...
(When PrintForm() is called, a printer settings dialog will popup. If OK is pressed, the printer will start printing... when the printer is ready to print it will call pdoc_PrintPge where you can alter its graphics object (e.Graphics ).
(You will need to set e.HasMorePages to false to print just one page).
PrintDocument pdoc;
PrinterSettings pset;
public void PrintForm()
{
pdoc = new PrintDocument();
pset = new PrinterSettings();
PrintDialog pdia = new PrintDialog();
if (pdia.ShowDialog() == DialogResult.OK)
{
pset = pdia.PrinterSettings;
pdoc.PrinterSettings = pset;
pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage);
pdoc.Print();
}
}
private void pdoc_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawImage(bmp, new Point(0, 0));
e.HasMorePages = false;
}
I hope this helps.
Matthew Butler
|
|
|
|
|
hi
i create a queue and service in my sql server 2005 by this code :
create queue myNotificationQueue
create service myService on queue myNotificationQueue
in my csharp code i wrote this code :
class Program
{
string connstring = null;
SqlConnection conn = null;
SqlDataReader rdr = null;
static void Main(string[] args)
{
Program c = new Program();
c.connstring = @"Data Source=MYLAPTOP\SQLLAPTOP;Initial Catalog=pubs;persist Security Info=True;User ID=sa;password=1";
c.conn = new SqlConnection(c.connstring);
c.DoWork();
Console.ReadLine();
}
private void DoWork()
{
conn.Open();
rdr = GetJobs();
if (rdr != null)
{
rdr.Close();
WaitForChanges();
}
conn.Dispose();
}
public SqlDataReader GetJobs()
{
using (SqlCommand cmd = new SqlCommand("Select job_id, job_desc from dbo.jobs", conn))
{
try
{
//cmd.Parameters.AddWithValue("@id", JobId);
SqlNotificationRequest not = new SqlNotificationRequest();
not.UserData = Guid.NewGuid().ToString();
// this must be a service named MyService in the pubs database
// associated with a queue called notificationqueue (see below)
// service must go by QueryNotifications contract
not.Options = "service=myService;local database=pubs";
not.Timeout = 0;
// hook up the notification request
cmd.Notification = not;
rdr = cmd.ExecuteReader();
while (rdr.Read())
Console.WriteLine(rdr[0]);
rdr.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return rdr;
}
}
public void WaitForChanges()
{
// wait for notification to appear on the queue
// then read it yourself
using (SqlCommand cmd = new SqlCommand("WAITFOR (Receive convert(xml,message_body) from myNotificationQueue)", conn))
{
cmd.CommandTimeout = 0;
object o = cmd.ExecuteScalar();
// process the notification message however you like
Console.WriteLine(o);
}
}
}
but when i compile it, and change jobs table, nothing occured. where does my problem ?
& How to solve my problem ?
thanks
|
|
|
|
|
WRONG FORUM...............................................................................................
its me sid
|
|
|
|
|
|
What is the core problem ? Working with delegates ? There are articles on CP about delegates, it's pretty easy. A delegate is a method which, when called, will call any number of methods that have the same signature, and have been assigned to that delegate. Events are delegates.
The code sample you linked to does not read fingerprints ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hey Christian,
No my core problem is reading the fingerPrint reader. I mentioned the delegates because I'm reading the book Visual C# 2005 step by step and that's where i am reading now.
Basically all i need to do is to grant access to my application using the finger prints. For that i think i need to read the finger print reader store the finger prints on the database and then whenever they need to run the application they can do so.
But I have no idea how to capture the images and as matter of fact i don't what to do...
The code sample from the link reads finger prints but first is in Visual Basic, which i can read but not port to C#, and second it is not complete.
What should i do?
I have until November 15th to finish this project, and there are so many small and security details to code that 5 days looks so small, if not i won't graduate from college...
Can u help me?
Regards
Luis E Tineo S
|
|
|
|
|
There are online tools to convert VB.NET snippets to C#.
How is it that you're 'not a programmer', but you need to finish a programming assignment to pass college ?
_GrFingerX.CapRawImageToHandle(raw.img, raw.width, raw.height, hdc, handle) get you the bitmap. What sort of database do you want to store it to ? Does the SDK offer methods to compare fingerprints ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|