|
SqlConnection conn;
string myquerry;
SqlDataReader reader;
SqlCommand command;
string uname, pass,type;
try
{
conn = myclass.connect();
if (conn.State == ConnectionState.Open)
MessageBox.Show("Sql Connection is Already Avaliable", "Connection Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
catch
{
MessageBox.Show("There is an Error Occured While Connecting SQL Server", "Connection Error",MessageBoxButtons.OK,MessageBoxIcon.Stop);
}
myquerry = "Select * from users";
command = new SqlCommand(myquerry, conn);
reader = command.ExecuteReader();
while (reader.Read())
{
uname = reader.GetString(0).Trim();
pass = reader.GetString(1).Trim();
type = reader.GetString(2).Trim();
idno = reader.GetInt32(3);
if ((textBox1.Text == uname) && (pass == textBox2.Text))
{
r = true;
break;
}
}
reader.Close();
if (r == true)
{
if (type=="ADMIN")
{
Entrance.ActiveForm.Hide();
Admin a = new Admin();
a.Show();
}
else
{
}
}
else
MessageBox.Show("Wrong UserName Or Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
//here is the sqlconnection code. use it myclass.connet()
string con_string = "workstation id=FIGHT_CLUB;packet size=4096;integrated security=SSPI;data source=FIGHT_CLUB;persist security info=False;initial catalog=proje";
SqlConnection mycon = new SqlConnection(con_string);
mycon.Open();
|
|
|
|
|
You store your passwords in clear text! Remind me never to your your site.
You also extract all the rows in the users table and iterate over them. That might be fine if you only have a couple of dozen users, but if the site is large this is extremely inefficient. I suggest adding some filters in the WHERE clause on the SQL statement.
|
|
|
|
|
Every webadmin use clear text! you should understand that how is your passwords are broken
but you r right, if use encoding it is best
|
|
|
|
|
|
Don't forget to encrypt the password in the database, just in case it gets cracked.
Programmer: A biological machine designed to convert caffeine into code. * Developer: A person who develops working systems by writing and using software.
[ ^]
|
|
|
|
|
As the title says really, is this possible? If so how?
Basically I have an application that has been developed and compiled agaisnt .Net Framework 1.1 SP1. For various reasons this cannot currently be converted to a .NET 2 application however I need to use some functionality that only exists in .NET 2.
After a little testing I have found, unsurprisingly, that it isnt possible to add the reference so I came up with a cunning plan to make the .NET 2 assembly a COM object and then get the 1.1 application to call the COM interface. Unfortunatly this does work either as added the COM reference fails with a "CLR assembly cannot be converted to CLR assembly" error.
My next plan of attack is to allow runtime binding of the COM object and then using DllImport in the 1.1 application. I will not be surprised if this doesnt work either. If this doesnt work my last ditch solution is to create an unmanaged wrapper around the .Net 2 library and code the 1.1 application to call that instead. However this is a bit of a faff, so does anybody have any alternative suggestions?
|
|
|
|
|
It is not possible AFAIK, because .NET 2 assemblies may use generics or other functionality that is not available on CLR 1.x.
There are other problems with this too: IIRC, only 1 CLR version can be loaded per-process. Attempting to load CLR 2 under a .NET 1.x process will introduce more problems, I believe.
What functionality are you after? Perhaps the functionality you're after could be reproduced in 1.x code?
|
|
|
|
|
Judah Himango wrote: There are other problems with this too: IIRC, only 1 CLR version can be loaded per-process. Attempting to load CLR 2 under a .NET 1.x process will introduce more problems, I believe.
You are correct, which is why I attempted (unsecuccesfully) to use a COM bridge
Judah Himango wrote: What functionality are you after? Perhaps the functionality you're after could be reproduced in 1.x code?
The need to use the HTTP post classes that support client side SSL certification, unfortunatly this wasnt added in .NET 1.1 - Up to today I have been using C# Libcurl wrapper code, however this is prooving to be quite bloated and unreliable. In .NET 2 I can perfom the same functionality in 10 lines of code. In the past I have also used code provided by Org.Mentalis however this prooved to be highly unreliable hence the reason for shifting to the C# Libcurl wrapper:
http://www.mentalis.org/soft/projects/ssocket/[^]
http://sourceforge.net/projects/libcurl-net[^]
|
|
|
|
|
Would it be feasible to use Reflector to look at the .NET 2 assembly code, then recreate something similar in your .NET 1.x project?
|
|
|
|
|
Hi, I have a problem using WMI (framwork 1.1), I get all live nodes scanned using the WMI Provider's ping service. But when I go to query those machines for any other information such as hardware (harddrive's info) I get an error "RPC Server unavilable".
I am logged in as Domain Administrator.
If any1 can guide me through this please.
Thank you!
Nauman Yousuf
|
|
|
|
|
The Ping server just bounces an ICMP packet off the remote machines network stack. It does NOT make sure the WMI service is reachable on the remote machine. The reason you're getting that error message is because the WMI services are not running, or are not installed, on those machines. Another possibility is that those machines are sitting behind a firewall that is filtering out the Remote Procedure Calls that are being made.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thank you! for your reply and It was useful.
I just have one more open issue i.e. I am unable to scan Machines outside of my Hub / Switch, I made sure that all machines have WMI Service running and they are on the same domain as mine (my machine is logged in as admin)
Thank you!
"Mess with the Best, Die like the rest"
|
|
|
|
|
Are the machines pingable by name AND IP? If they're pingable by IP, but not by name, then there ius a name resolution problem (DNS).
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
hi, i used ShockWaveFlash in my windows application.
i want to disable default ContextMenu for shockWaveFlash when my form runs.
how i can do it ?
thanks
|
|
|
|
|
What im trying to do is convert an image to a byte[], then write that byte array to an XML file as a string. I then want to be able to read back that file and convert the string to a btye array and then back to the image.
ASCIIEncoding encoding = new ASCIIEncoding();<br />
byte[] imageArray = ImageToByteConvert(style.Image);<br />
string imageString = encoding.GetString(imageArray);<br />
<br />
writer.WriteAttribute("Image", imageString);<br />
<br />
public byte[] ImageToByteConvert(Image imageIn)<br />
{<br />
MemoryStream ms = new MemoryStream();<br />
imageIn.Save(ms, ImageFormat.Gif);<br />
return ms.ToArray();<br />
}<br />
<br />
----<br />
<br />
attribute = domNode.Attributes["Image"];<br />
if (attribute != null)<br />
{<br />
byte[] imageByte = encoding.GetBytes(attribute.Value);<br />
retval.Image = ByteToImageConvert(imageByte);<br />
}<br />
<br />
public Image ByteToImageConvert(byte[] byteArrayIn)<br />
{<br />
MemoryStream ms = new MemoryStream(byteArrayIn);<br />
Image returnImage = Image.FromStream(ms);<br />
return returnImage;<br />
}
The problem is im getting an error saying:
03/01/2007 14:31:31 XmlModelSerializer.SerializeContent; Exception: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.<br />
at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)<br />
at System.Drawing.Image.Save(Stream stream, ImageFormat format)<br />
at XmlModelSerializer.ImageToByteConvert(Image imageIn) in line 61<br />
at XmlModelSerializer.SerializeContent(IWriteContext context, SeverityNodeStyle style, IXmlWriter writer) in line 33
Line 61 is: imageIn.Save(ms, ImageFormat.Gif);
Any ideas?
Regards,
Gareth.
|
|
|
|
|
You would get the very informative message "A generic error occurred in GDI+" for
almost anything that can go wrong in Image.Save().
When saving to a file on disk it could be disk full, network disk disappeared,
file is locked, file is read-only, whatever. I dont know which of these have an
equivalent when saving to a memory stream.
It might also be a basic limitation of the GIF format (e.g. too many colors).
Are you sure you want GIF ?
And it could be a GDI bug (unknown to me).
Take your pick !
I would experiment with another format, say JPEG, at least to see if that works under
identical conditions...
Luc Pattyn
|
|
|
|
|
I tried changing the ImageFormat to .Jpeg, didnt change anything.
|
|
|
|
|
Hi Gareth,
I did some experiments with Image.Save() to memory stream, nothing went wrong.
Do you have your problem with every image ?
with the image(s) that goes wrong, does it fail on every attempt ?
is anything special about such image ? (size, number of colors, way it was created, ...) ?
what is its size ?
do you have a file containing such image, if so could you mail one failing image to me ?
furthermore, you could try to save GIF format to file instead of to memory stream,
then have a look at the file to see how large it gets (i.e. how far
the save operation succeeds), and (with hex viewer) possibly what is wrong.
If saving to file also fails, I could have a look to that file too...
Greetz
Luc Pattyn
|
|
|
|
|
Hi Luc,
It fails everytime on the same image and on different images. The image is only a 16x16 image, so is pritty small. How do i find out your email?, since i cant seem to view your profile.
Regards,
Gareth.
|
|
|
|
|
Ive kind of fixed the problem. Its being caused because i dont have write permissions i think, because if i specifiy the actual file location, eg: C:\ci.gif, i dont get the error. But if i try to get the image from my get/set method, the error appears.
The next problem i get through is when converting the image to bytes and visa versa.
public string ImageToByteConvert(Image imageIn)<br />
{<br />
MemoryStream ms = new MemoryStream();<br />
imageIn.Save(ms, ImageFormat.Gif);<br />
<br />
string imageString = Convert.ToBase64String(ms.ToArray());<br />
return imageString;<br />
}
I then write that string to the XML file which works fine. But if i try to read it back
byte[] imageByte = encoding.GetBytes(attribute.Value);<br />
retval.Image = ByteToImageConvert(imageByte);
I get an error saying:
05/01/2007 11:57:37 XmlModelSave.ReadGraph; Exception: System.ArgumentException: Parameter is not valid.<br />
at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData)<br />
at System.Drawing.Image.FromStream(Stream stream)
Which i believe to mean the bytes that i have just converted back from a string, arnt valid for the image im trying to create. But im unsure how to solve this.
Regards,
Gareth.
|
|
|
|
|
Hi Gareth,
I looked into your GIF file and did some experiments on it.
I was able to read the image, modify and save it, but something weird happened
to the background color.
Upon closer inspection of your image, it seems to have a 6-bit color scheme,
but a background color index of 255. This seems like an invalid combination.
Hence:
1) I wonder how you created such an image in the first place
2) I am surprised GDI+ does not throw an exception (one of those nice "a generic
error occured" messages)
Regards,
Luc Pattyn
|
|
|
|
|
I didnt create the image, it was already created before i started working on this current project.
|
|
|
|
|
|
which of events to use, and if none of them is actually one for this purpose I though of using KeyPress, but not sure how to make expresion that check if key is Enter (and then execute some method)???
|
|
|
|