|
Could you provide the error detail.. I think some other issues are there....
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
There are so many things wrong with this! For example:
Mangesh Tomar wrote: connection.Open();
string selectString =
"SELECT Name, Password " +
"FROM login1 " +
"WHERE Name = '" + login.Text + "' AND Password = '" + psw.Text + "'";
cmd = new OleDbCommand(selectString, connection);
connection.Open();
Why try to open it twice?
Mangesh Tomar wrote: String strResult = String.Empty;
if (strResult.Length > 0)
{
label5.Text = "YOU ARE LOGGED IN!";
}
What do you think is going to happen? Magic?
I sugest you go right back to the begining - create a new project, connect to that database and read a single record from the table. When you get that working, start building up from there.
Oh, and Luc is right - preserve your formatting with <pre> and </pre> tags around you original code when you post it here. It make it easier to read, and thus more likely to be read. (And Luc is one of the people you really want to read your code - you will probably never learn half the stuff he has forgotten...)
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Hello.
Does anybody know, I'm searching for control, that can be created Icon automatically in taskbar, for example for showing network speed.
I just have an idea to create it manually, using Bitmap class, but I must draw it pixel for pixel. (For example: 100M)
Are there any easier way ?
Thanks.
|
|
|
|
|
hi guy,
you want show different icons in the systemtray for some actions that nobody knows. how can we make this dynamic without snipping with the finger ^^ you understand ^^
make your bitmaps with paint.. or some else and load it at runtime.
greetz
|
|
|
|
|
Dynamically created Icon for "Number" in Taskbar
Just 0...9
|
|
|
|
|
load bitmaps ^^
or draw the 0..9 to a bitmap from string then create the icon and show it ^^
|
|
|
|
|
Hi,
this draws into a bitmap:
Bitmap bm=new Bitmap(100,100);
Graphics g=Graphics.FromImage(bm);
g.FillRectangle(...);
g.DrawString(....);
and this turns a bitmap file into a simple icon file:
string filename=...;
try {
Bitmap bm=(Bitmap)Image.FromFile(filename);
if(bm.Width!=32 || bm.Height!=32) {
bm=new Bitmap(bm, 32, 32);
}
Icon icon=Icon.FromHandle(bm.GetHicon());
bm.Dispose();
string filename2=Path.ChangeExtension(filename, ".ico");
Stream stream=new FileStream(filename2, FileMode.Create);
icon.Save(stream);
log("Created icon "+filename2);
} catch(Exception exc) {
log("Failed to create icon from "+filename);
log(exc.ToString());
}
If all you need is a few different icons, run such code once and save the result as files or resources.
:)
<div class="ForumSig">Luc Pattyn
<hr>I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
<hr>Local announcement (Antwerp region): Lange Wapper? Neen!
<hr></div>
|
|
|
|
|
i have the following code
this code runs on LogIn form Acts as standby while other forms still opened
if(Application.OpenForms["MainForm"].MdiChildren.Length>0)
{
MessageBox.Show("!..you should close all opened windows before continue", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
Application.Exit();
}
when code running LogIn form disappeared and user can access any opened form
i want to only keep LogIn form running untill entering valid password
|
|
|
|
|
Dont use "Application.Exit();"
It will kill all forms and end your application.
Just close your MainForm and don't close your LoginForm.
|
|
|
|
|
hi,
only show your MainForm after a valid passord entered! is a much easier way..
and to cancel the OnClosing use CancelEventAgruments.Cancel = true
bless
|
|
|
|
|
|
I think this is constant for all the document you generate...design your template by considering this...
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
Hi all
do you know a way to amutomatic add a method to a class once this last is decorated with a C# custom attribute?
Thanks
MN
[MyAttribute("MyName")]
public class CA
{
public CA()
{}
};
CA obj = new CA();
obj.MethodDueToMyAttribute();
|
|
|
|
|
No, attributes only provide additional meta data, they can't do anything like that.
The only way to achieve that would be if the C# compiler detected the attribute and added the method when the class was compiled. Obviously, as you can't change the code for the C# compiler it's not something you can do - unless you fancy writing your own C# compiler.
I suppose you could add a pre-build event that searched through all the classes for the attribute and added the method, but as it would be running before the compiler, you would have to just to a text based search and modify the .cs file before it was compiled.
Simon
|
|
|
|
|
manustone wrote: CA obj = new CA();
obj.MethodDueToMyAttribute();
when class CA does not have a MethodDueToMyAttribute method at compile time (and there isn't a class holding an extension method for CA), this code will not compile.
Hence, you can create another DLL file with new functionality at run-time, however invoking the new stuff will take reflection code, not a simple call to a yet unknown method.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
|
egpuyos wrote: Dictionary myDictionary = new Dictionary();
Does this even compiles?
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
sorry it was
Dictionary<byte[], string> myDictionary = new Dictionary<byte[], string>();
|
|
|
|
|
What do you think the output of:
string test = "test";
byte[] b1 = Encoding.Default.GetBytes(test);
byte[] b2 = Encoding.Default.GetBytes(test);
Console.WriteLine(b1 == b2); It will be false as arrays are reference type and compared with reference equality. This is the reason why your code fails. BTW, what is wrong in keeping the string itself rather than the bytes?
|
|
|
|
|
Actually Sir, it was just my sample code, the real code I have is this.
I don't understand why that the dictionary when I call the method Exists, it will return false while it already contain the key that I passed? How could it happen?
Thank you again with you're help Sir.
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
private static Dictionary<byte[], string> m_MyDictionary = null;
private static System.Text.ASCIIEncoding m_MyEncoding = new ASCIIEncoding();
static void Main(string[] args)
{
m_MyDictionary = new Dictionary<byte[], string>();
AddDataToDictionary();
Console.Write(Exists(m_MyEncoding.GetBytes("test 003")));
Console.Read();
}
private static void AddDataToDictionary()
{
string s;
byte[] myByte;
s = "test 001";
myByte = m_MyEncoding.GetBytes(s);
m_MyDictionary.Add(myByte, s);
s = "test 002";
myByte = m_MyEncoding.GetBytes(s);
m_MyDictionary.Add(myByte, s);
s = "test 003";
myByte = m_MyEncoding.GetBytes(s);
m_MyDictionary.Add(myByte, s);
s = "test 004";
myByte = m_MyEncoding.GetBytes(s);
m_MyDictionary.Add(myByte, s);
s = "test 0021537912";
myByte = m_MyEncoding.GetBytes(s);
m_MyDictionary.Add(myByte, s);
s = "test 327487";
myByte = m_MyEncoding.GetBytes(s);
m_MyDictionary.Add(myByte, s);
}
private static bool Exists(byte[] key)
{
return m_MyDictionary.ContainsKey(key);
}
}
}
|
|
|
|
|
Dictionary.ContainsKey checks for value on value types, for reference on ref types.
As N a v a n e e t h said, two arrays with identical type, size and content are considered different, they are two distinct objects with different references.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
This is the whole code Sir, thank you with the help
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Dictionary<byte[], string> myDictionary = new Dictionary<byte[], string>();
System.Text.ASCIIEncoding myEncoding = new ASCIIEncoding();
string s;
byte[] myByte;
s = "test 001";
myByte = myEncoding.GetBytes(s);
myDictionary.Add(myByte, s);
s = "test 002";
myByte = myEncoding.GetBytes(s);
myDictionary.Add(myByte, s);
s = "test 003";
myByte = myEncoding.GetBytes(s);
myDictionary.Add(myByte, s);
s = "test 004";
myByte = myEncoding.GetBytes(s);
myDictionary.Add(myByte, s);
s = "test 0021537912";
myByte = myEncoding.GetBytes(s);
myDictionary.Add(myByte, s);
s = "test 327487";
myByte = myEncoding.GetBytes(s);
myDictionary.Add(myByte, s);
string theString = "test 004";
byte[] find = myEncoding.GetBytes(theString);
if (myDictionary.ContainsKey(find))
{
Console.Write(find);
}
else
{
Console.Write("key not found.");
}
Console.Read();
}
}
}
|
|
|
|
|
hi,
you use the byte array as key instead of the string you are adding as value ?!?
why you don't add the string as key and the byte array as value. in your code above i see that would make no difference to the functionality and i think that would be the better way.
greetz
|
|
|
|
|
hey all,
i want to create a window service which send mail automatically at a given interval or any other condition.service should start with system boot n stop with system shutdown . i am not familiar with window services. thanks in advance for ur help n rplies.
|
|
|
|
|
Hi,
have a look here:
Simple Windows Service Sample[^]
It is a little bit old (e.g. using VS 2003), but the idea behind the article is still actual.
Regards
Sebastian
|
|
|
|