|
|
hello sir this is ramakrishna. I want to store and retrive the image from database(Access) throgh c# code.please give me the solution.
|
|
|
|
|
Google will give you more results (and code) than any expert in CP. This[^] is the third result in the search.'
[EDIT]Use a meaningful title for your posts that explains your problem. 'C#' doesn't make a good title.[/EDIT]
|
|
|
|
|
|
The OP clearly mentioned Access as the database, yet you gave him a link to SQL Server.
|
|
|
|
|
|
Search here on CP. You should be able to find some good examples.
A similar question[^] was answered some time ago.
Too much of heaven can bring you underground
Heaven can always turn around
Too much of heaven, our life is all hell bound
Heaven, the kill that makes no sound
|
|
|
|
|
Hi Friends
I'm Trying To Create A Custom Form Using System.Drawing Namespace's Classes
But I Don't Know How To Create Event Logic Such As Onclick
And I Don't Know How To Create Any Behaviors That a Visual Form Can Do.(Such as Moving , Painting,Activateing and So on).
How To Do it.
Thanks
|
|
|
|
|
I suggest you start by making your own custom Control first. That way you can learn the answer to such questions in a 'safe environment'. There's probably plenty of guides on how to build a custom control, with its own specific events and painting.
Once you've got the hang of that, you can try at an actual form.
|
|
|
|
|
Thank You For Your Answer
there Are Three Basic Techniques For Creating A control.We Can
1.Inherit From An Existing Control
2. Inherit From User Control
3.Inherit From Control
Each Of Techniques Above has Advantages And Defects.I Don't Know Which Of Techniques Is better For My Solution.
I Want to Create A New Shell Like Windows Themes. Is a Reference That I Can Use It To Find Out Any Answer.
Thanks To All Answers.
|
|
|
|
|
Which is best depends on your situation.
1) Inheriting from an existing control. Use this approach if there already exists a control which does most of what you want, and you want to add to it and/or change some of its functionality. A lot of the standard controls in .NET allow most of their functionality to be overwritten by virtual functions, in effect allowing a great deal of customisation, building on existing blocks. It requires you to familiarise yourself with the control in question. A great advantage to this approach is that a lot of the functionality you want is already implemented and you only need to work on the parts you want added or different. How far you can go in customisation (and how easy) depends on the specific control.
2) Inheriting from UserControl allows you to begin with 'a clean slate'. It has basic functionality to help you start a new control, such as auto-scrollbars and it's a control container out of the box. You create a custom control from this typically by combining existing controls. Since you express interest in mostly changing the look of the controls, this is probably not the best for you.
3) This allows you the most power, starting from scratch. Some functionality is right out of the box, but most you're going to have to build yourself. It's very powerful, but also the most work of the three. Best suited if you are creating an entirely new control that 1) doesn't behave like an existing control, or a group of existing controls and 2) has a unique look, so it needs to do all of its own drawing. This is the most advanced of the three.
I'm guessing you're best of with method Nr 1 - inheriting from existing controls. You can override the paint event to do your own drawing. That way, you can change the looks while preserving the functionality. But it's up to you to decide.
There are plenty of articles about creating a custom control, also here on CodeProject. Look for articles like "Custom <name> control", where name is the name of an existing control, e.g. "Custom progressbar control".
Good luck!
|
|
|
|
|
if you merely want your form to appear different than the Form class but exhibit exactly the same behaviour you may want to look into subclassing Form and overriding the onPaint method to apply your own graphics
|
|
|
|
|
In my meanderings through weird code ideas, I wrote down some simple classes in C# based on the idea of "What if variables were typed based on what they returned when called, using that as what they are."
So, for example, an equation that returns a double "is" a double (or derived from DTBase(double)); a DTFunc(string) that concatenates a string based on relevant factors "is" a string (or derived from DTBase(string)) and, of course, a DTVar(int) contains and "is" an integer. (Parenthesis substituted for angle brackets)
Being as this website is about code and being that I wrote this in C#, I decided to see what other programming netizens might think of this idea, as well as the rather present idea that someone may have thought of this first.
Thanks.
modified on Friday, August 26, 2011 9:16 PM
|
|
|
|
|
So what's the difference from the current state of things?
|
|
|
|
|
Currently?
Invalid in current state of things:
double a = new Func<double>(delegate() { 2 + 2; });
Granted, a very simple example, but it helps lay the groundwork for the second example.
Valid in my Dynamic-Typed paradigm:
DTBase<double> a = new DTFunc<double>(delegate() { 2 + 2; });
Console.WriteLine(a.Call);
a = (DTVar<double>)5;
Console.WriteLine(a.Call);
DTBase<double> a = new DTEquation((DTVar<double>)1, new DTOperand[] { new DTOperand(MathOp.Add, (DTVar<double>)1) });
Console.WriteLine(a.Call);
And in that equation, I could have put any type derived from DTBase(double), including functions, dice rolls, or, yes, other equations.
So not *quite* the current state of affairs.
|
|
|
|
|
For the amusement and edification of any readers - What may be the first actual DynamicTyped program (if someone else didn't yoink the idea first)
Provided simply to provide actual code, it accepts a sequence of numbers and outputs a formatted string:
DTFunc<double, string> f = new DTFunc<double, string>(
a =>
{
string r = "";
while (a.Count > 0)
{
r += a.Call + ", ";
}
return r.Length > 0 ? r.Substring(0, r.Length - 2) : r;
}
);
for (int i = 0; i <= 10; ++i)
f.Args.Add = i;
Console.WriteLine(f.Call);
Output: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Now, if I change its arg type to DTBase(double), I could feed all kinds of things into there - Variables, equations, dice rolls, other functions, file reads (not currently, but potentially)...So long as they all returned a double when called.
|
|
|
|
|
Reading this code I don't have a clue what you are doing: the function(?) 'Call is not shown, the meaning of 'Args' is opaque.
"In the River of Delights, Panic has not failed me." Jorge Luis Borges
|
|
|
|
|
Essentially? Adds the numbers 0 to 10 to the functions' arguments. The function then iterates through those arguments and constructs a comma-separated string.
"Call" is a general property that returns "Whatever it is the object does/is". In the case of the function, it calls the function. In the case of DTArgs, it dequeues the next argument.
In comment-o-vision:
DTFunc<double, string> f = new DTFunc<double, string>(
a =>
{
string r = "";
while (a.Count > 0)
{
r += a.Call + ", ";
}
return r.Length > 0 ? r.Substring(0, r.Length - 2) : r;
}
);
for (int i = 0; i <= 10; ++i)
f.Args.Add = i;
Console.WriteLine(f.Call);
I have no idea how well I'm explaining things (which tends to make my explanations rather...Bad), but hopefully I've cleared up at least a little confusion.
|
|
|
|
|
How is that different than "var"?
|
|
|
|
|
Valid in current paradigm:
var a = 5.5;
Invalid in current paradigm, but valid if paradigm theoretically adopted by C#:
a = new func<double>(delegate() { return 5.5; });
Using a theoretical library of additional functions, both are valid:
DTBase<double> a = (DTVar<double>)5.5;
a = new DTFunc<double>(delegate() { return 5.5; });
The key point is that, instead of being a specific type of variable, "a" is now defined by what you get when you call it.
|
|
|
|
|
And here is a heavily-commented "Guess My Number" game using this paradigm (granted, it's not runnable without the classes, but it is heavily-commented. Should I release that code? I've no idea if anyone is the least bit intruiged):
DTVar<int> length = 7;
Console.WriteLine("Guess my Number, a {0}-digit number.", length);
DTVar<bool> allCorrect = false;
DTFunc<char, char, string> matchingF = new DTFunc<char, char, string>(
(a, b) =>
{
string r = "";
while (a.Count > 0)
{
char a1 = a;
char b1 = b.Call;
r += (a1 == b1 ? a1 : 'X');
}
return r;
}
);
DTBase<string> numberF = new DTFunc<string>(
delegate()
{
string r = "";
for (int t = 0; t < length; ++t) r += Rand.Next(10);
return r;
}
);
DTBase<string> guessF = new DTFunc<string>(delegate() { return Console.ReadLine(); });
DTFunc<string, bool> correctF = new DTFunc<string, bool>(a => { return !a.Call.Contains('X'); });
DTVar<string> number = numberF.Call;
int count = 20;
do
{
DTVar<string> guess = guessF.Call;
matchingF.Args1.AddRange = number.Call;
matchingF.Args2.AddRange = (string)guess;
DTVar<string> result = (string)matchingF;
correctF.Args.Add = result;
allCorrect = correctF.Call;
Console.WriteLine(result.Call);
} while (!allCorrect && --count >= 0);
Console.WriteLine("You {0}", (allCorrect ? "Win! :)" : "Loose. :("));
|
|
|
|
|
Hi Narf,
I think this kind of experimentation is a very cool thing to do: at a minimum you will come to a greater understanding of what the language limits are, and your creativity is definitely showing here !
I don't have the 'bandwidth' or inclination to study your code and figure out what you are doing, but it seems to me that you are moving C# one step past 'var' and 'dynamic' towards behaving like more loosely-typed languages (Haskell ? Ruby ?).
For me there's so much built-in to .NET in its current highly-evolved state, that I am going to stick with it, as is ... and it's evolving rapidly.
If I want a List of integers converted to a string, (as early as .NET 2.0, I believe), I can use Linq like this: (and there may well be a simpler way: I'm no expert on Linq):
List<string> s = new List<int> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}.ConvertAll(i => Convert.ToString(i));
So, please do, keep going, follow your vision ! Don't let those who 'don't get it' phase you in the least
best, Bill
"In the River of Delights, Panic has not failed me." Jorge Luis Borges
modified on Monday, August 29, 2011 11:34 PM
|
|
|
|
|
I think there is an interesting discussion to be had here but I don't quite see what you are gaining over a Func<double> (with DTFunc<T>), or just a normal variable with DTVar.
|
|
|
|
|
I apologize if you did read this particular post, but it sounds like you didn't, so I'm reposting it.
<quote>
Valid in current paradigm:
var a = 5.5;
Invalid in current paradigm, but valid if paradigm theoretically adopted by C#:
a = new func<double>(delegate() { return 5.5; });
Using a theoretical library of additional functions, both are valid:
DTBase<double> a = (DTVar<double>)5.5;
a = new DTFunc<double>(delegate() { return 5.5; });
The key point is that, instead of being a specific type of variable, "a" is now defined by what you get when you call it.
If you're wondering what use being able to type variables by what they return when "called" is, a few suggested thoughts are:
Dictionary<string, DTBase<double>> formulasForGame;
List<DTBase<string>> urlRetrieval;
List<DTFunc<string, string>> chatRelays;
And any other situation where you want a generic, quick way to access data by type, not implementation. That is to say, counting double and Func(double) as separate implementations, but the same type.
Thank you for your patience and interest.
|
|
|
|
|
This:
a = new func<double>(delegate() { return 5.5; });
... may be invalid if you declare a as double, but if you want this kind of flexibility, surely you can use Func<double> in most cases (and when you want a constant, write a lambda or anonymous delegate to return it, as here).
I guess that is possibly useful in some cases though.
What is the performance hit like on this? You are adding a lookup (or method call) each time the 'variable' is referenced?
Have you considered:
public implicit operator T(DTBase<T> val) { return val.Value; }
public implicit operator DTBase<T>(T val) { return new DTVar<T>(val); }
That would make your implementation almost transparent.
|
|
|
|
|