|
There are several examples[^] on the Internet.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
I have two Access mdb files with identical table structure...I need to insert records that do exist in the firtst from the second mdb file. What is the appropriate and the best way to do it? Working with dataset maybe?
Thank you
|
|
|
|
|
Have you looked at DataTable.Merge ?
only two letters away from being an asset
|
|
|
|
|
Not yet...but I will. I am still learning.
Thank you
|
|
|
|
|
|
Catherine88 wrote: Write a simple game program ...
Written in the imperative rather than the interogative... That suggests that this is a homework assignment. So, what have you written so far and what are you stuck on?
|
|
|
|
|
First, don't ask for URGENT help, it may be urgent to you, but not to the rest of us.
Second, don't ask for homework help unless you have actually attempted it and have a specific coding related question.
only two letters away from being an asset
|
|
|
|
|
Don't say urgent, it is considered very rude around here.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hy there..I still can't figure out how to do this. I have a control that has a public Brush property, but I can't get it to be serialized in InitializeComponent()
What have I done wrong? I know that Brush is an abstract class..but Image is to..and that doesn't stop, for ex, the BackgroundImage property to get serialized..
|
|
|
|
|
If you use Reflector, you can see that the Image class declares that ImageConverter should be used as it's TypeConverter. As shown here:
[Serializable,
...,
TypeConverter(typeof(ImageConverter))]
public abstract class Image : MarshalByRefObject,
ISerializable, ICloneable, IDisposable
{
}
ImageConverter is what is used by Visual Studio to "serialize" the Image for use by InitializeComponent. There is no TypeConverter defined for the Brush class (nor SolidBrush, TextureBrush, etc). So these types cannot be serialized as you want.
Typically, controls would expose other properties and build the Brush when needed. So you could define a Color property, then build a SolidBrush when you are performing your drawing. Or if you want a TextureBrush, you would have a Image property.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Hmm,thanks for the answer,it makes sense. But..I can't figure out why visual studio doesn't use my custom type converter for that property. I use it like this:
<br />
[TypeConverter(typeof(BrushConverter))]<br />
public Brush Brush<br />
{<br />
get<br />
{<br />
...<br />
I mean..it uses the BrushConverter to convert from Brush to string and back..but it doesn't use it to convert from Brush to InstanceDescriptor(i.e the class that tells it how to serialize the code).
I want the developers to choose the type of brush they want to use. What if I make the property if type string..and parse the string in the OnPaint() ? That is kind of weird..but it might work.
Any ideea why can't I use a custom converter for the property?
|
|
|
|
|
If you can email over the code to BrushConverter, then I can take a look.
Your last question brought up another option, which is to provide two properties (e.g. Brush and BrushString). The Brush property would not be serialized (e.g. there should be a ShouldSerializeBrush() method that always returns false). The BrushString property would be serialized, but would not be browsable. This way it will save the "string" (or byte[]) which would hold the serialized version of the Brush in the designer code.
In the "get" for BrushString, you would serialize the Brush into a string and return that. In the "set" for BrushString, you would deserialize the Brush and save it. The Brush property would work normally.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
I have a program.
it need to process a little of data when data modifed in database(update or insert new or delete).How to get this data real time?
Or how program get the data from database's trigger?
|
|
|
|
|
|
MSDN:"SqlDependency was designed to be used in ASP.NET or middle-tier services where there is a relatively small number of servers having dependencies active against the database."
Mine is WinForm program, can use it too?
|
|
|
|
|
|
It works:
var names = from n in db.Contacts
where n.Name.Contains("aaa")
select n;
foreach(var t in names)
{
t.Name = "xxx";
}
db.SubmitChanges();
Not works (no errors but the Name field does not change)
public class tmp
{
public string Name {get; set;}
public int ID { get; set; }
public string Group { get; set; }
}
var names = from n in db.Contacts
where n.Name.Contains("aaa")
select new tmp { Name = n.Name, ID = n.Id, Group = n.Group.Name };
foreach(var t in names)
{
t.Name = "xxx";
}
db.SubmitChanges();
how can I do this without fetching all database columns?
Thanks
|
|
|
|
|
Sorry, if you are trying to update the Name on the contact object, then you will need to select the contact object (as you do with the first code example).
In the second example you are creating a new object (with the same Name, Id and Group), and updating it's name. You are not updating the original contact object.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
I thought about this, but I did hope it's my mistake. So, there is no way to have an "updateable select" using just a few of table columns? The original goal was something like:
dataViewGrid.DataSource = from .....
and permit updates, ... in grid having just 3-4 columns (not all 15).
|
|
|
|
|
Yes it should be possible to only retrieve 3-4 columns from a DB table and still allow those columns to be updated. This is assuming ofcourse that one of those columns is a unique identifier for the associated row (e.g. the Primary Key).
For your code, it really depends on what db.Contacts returns. Since I can't see that code, I'm assuming that it returns a list of Contact objects that have all 15 columns. In order to only return 3-4 columns, then the Contact object would need to only have the 3-4 columns.
If you can provide some more of the code that would help (either through email or here). Let me know if this doesn't make sense also. But basically, the "object" that holds the data for a single row in your table is what must be updated. Therefore, you would need to change how many columns the "object" has before the code you posted earlier.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
db.Contacts and 3 more classes are generated by sqlmetal, the solution would be to modify this classes to have properties just for database columns I need? (the primary key is in my "column-wish-list"). This probably would work but it seems to me way to complicated and across the program there are about 5 column combinations.
Thanks
|
|
|
|
|
I want to set the file of types in Open File Dialoge to a specific type such as ".bmp"
|
|
|
|
|
Why don't you read the documentation? OpenFileDialog has a property called filter which allows you to set file type.
|
|
|
|
|
could u please give me an example on how to use it !
|
|
|
|
|
As I already said in my first reply, why don't you read docs? Or google? Or search here, on codeproject? No one is going to do it instead of you. Learn googling.
|
|
|
|