|
Hi
In my login form i have set user name Password as "admin" and "sa"
if i type ADMIN and SA it should not work but its working..
how resolve it
thanks in advance
|
|
|
|
|
Mads115 wrote: In my login form i have set user name Password as "admin" and "sa"
if i type ADMIN and SA it should not work but its working..
how resolve it
How did you checking the use id and password? Where is the code? Did you check with String.Equal() or what ?
|
|
|
|
|
this is the Code I am using
SqlConnection Con1 = new SqlConnection("server=.;database=ab;uid=sa;pwd=max");
Con1.Open();
SqlCommand cmd1 = new SqlCommand("select UserName,Password from mads Where Username= '" + usrtxt.Text + "' and Password ='" + passtxt.Text + "'", Con1);
SqlDataReader dr = cmd1.ExecuteReader();
dr.Read();
if (dr.HasRows == true)
{
prj = new Project_Details(usrtxt.Text);
prj.Show();
}
dr.close;
|
|
|
|
|
SQL is case insensitive. You have to force SQL to turn on the case sensitivity for the select query. Just add the following clause with your select query:
COLLATE SQL_Latin1_General_CP1_CS_AS
Use COLLATE SQL_Latin1_General_CP1_CI_AS for case insensitivity.
It can solve your problem.
Regards
Saanj
Either you love IT or leave IT...
|
|
|
|
|
Mads115 wrote: SqlCommand cmd1 = new SqlCommand("select UserName,Password from mads Where Username= '" + usrtxt.Text + "' and Password ='" + passtxt.Text + "'", Con1);
If this is your live code, Please be careful about SQL Injection .
|
|
|
|
|
Check out the following code:
if (string.Compare("hello", "Hello", false) == 0)
{
//do whatever you wish
}
The third parameter makes the string comparison case sensitive.
Regards
Saanj
Either you love IT or leave IT...
|
|
|
|
|
Hi, i have a problem about threads with windows forms.
When users's sessions ended, i want to show a dialog box to inform them to relogin and then to show the relogin form.
It was ok until i use threads in some forms to improve performance.
When a thread reveices a session error, it shows the relogin form. Actualy i use invoke on the main thread.
But while the dialog form is shown, another thread can make a service call and receive the same session error and so tries to show the same relogin form. But it is clear that only one instance of relogin form must be shown at the same time. So i have to use a locking mechanism. But since the thread that shows the dialog box is the main thread, this causes the main thread enter wait state. So the application freezes.
public bool Relogin() {
Interlocked.Increment(ref waitingThreadCount);
event1.WaitOne();
if(this.loginResult == null) {
loginResult = ReloginForm.Show();
}
Interlocked.Decrement(ref waitingThreadCount);
if(waitingThreadCount == 0) {
loginResult = null;
}
event1.Set();
return loginResult.Value;
}
modified on Thursday, June 11, 2009 2:40 AM
|
|
|
|
|
Hi,
I have CrystalActiveXReportViewerLib11_5.dll for my application. I have used a typed Dataset. In this DataSet there are two DataTables DataTable1 and DataTable2. DataTable1 is used for main report and DataTable2 is for SubReport. When i set DataSource for both DataTable i got a problem. For only one dataTable it is ok.
Any help for this problem is appreciated. It is urgent. My code is like this:
DataTable dtt1 = LoadDataTable();
DataTable dtt2 = LoadFriendDataTable();
CRAXDDRT.Application crxApp = new CRAXDDRT.Application();
CRAXDDRT.Report crxReport = new CRAXDDRT.Report();
crxReport = crxApp.OpenReport(Application.StartupPath+"\\rptHouseLandTaxLetter.rpt",null);
crxReport.Database.Tables[1].SetDataSource(dtt1, null);
//crxReport.Database.Tables[2].SetDataSource(dtt2, null); //error occurred here
this.crViewer.ReportSource = crReport;
this.crViewer.ViewReport();
private DataTable LoadDataTable()
{
CrystalReportTest1.DataSet1.DataTable1DataTable dtReport = new DataSet1.DataTable1DataTable();
foreach (DataRow dr in dt.Rows)
{
dtReport.Rows.Add(dr.ItemArray);
}
return dtReport;
}
private DataTable LoadFriendDataTable()
{
CrystalReportTest1.DataSet1.DataTable2DataTable frienddt = new DataSet1.DataTable2DataTable();
foreach (DataRow dr in dt.Rows)
{
frienddt.Rows.Add(dr.ItemArray);
}
return frienddt;
}
modified on Wednesday, June 10, 2009 12:59 AM
|
|
|
|
|
Hi,
I am trying to add ecgraph3d control to my project using VS 2005, the error "failed to import the activex control. please ensure it is properly registered" poped up.
I need help to fix this problem. Thank a lot in advance!
Brandon.
|
|
|
|
|
Have you registered the control ?
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Yes, I did register control using regsvr32.exe
I have been using a lot of ocx control so far and this is the only one give me that error.
Thanks,
Brandon
|
|
|
|
|
Assuming your control got registered successfully, try clearing all the files in obj/debug or obj/release. Now try to add the control again.
If you have problem in registering control using regsvr32 , use dependency walker and profile regsvr32 by specifying the dll to be registered.
|
|
|
|
|
Navaneeth,
I have tried many time to delete the files in obj and debug folder but the error is still there.
I am not sure I have problem using regsvr32 or not since I have used to register a lot of controls so far. All works fine, except this control ecgraph3D.ocx
How can I use dependency walker and profile regsvr32 ?
Many thanks,
Brandon
|
|
|
|
|
brandonwong123 wrote: I am not sure I have problem using regsvr32 or not
The problem is obviously going to be specific to the control.
Does the control come with any samples ? Do they work ?
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Christian,
The control comes with visual basic 6 example and it works on my machine. This company has ecgraph.ocx and it works on my visual studio 2005. Now they just have ecgraph3D.ocx as their new product but this control doesn't want to work on my C# 2005
Thanks,
Brandon
|
|
|
|
|
So the VB6 sample you have is for the new control, or the old one ? If that works, then the issue is somewhere in how you're importing the file.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Christian,
The VB6 example is for the new control. I just try to add control on different computer and error is the same.
I am not sure what is causing this problem.
Any further help, please let me know.
Thanks,
Brandon
|
|
|
|
|
Hello All,
I hope someone can help. I have a dataGridView populated with data, I have added a dataGridViewComboBoxColumn. The dataGridViewComboBoxColumn is populated per row. That all works great. The issue I am having is getting the value of a dataGridViewComboBoxColumn Cell.
The last thing I tired is:
DataGridViewComboBoxCell cell = dataGridView1[cntR, cntC] as DataGridViewComboBoxCell;
string val = cell.ValueMember.ToString();
string val2 = cell.Value.ToString();
Which always returns "" for both.
Any help would really be great.
j
|
|
|
|
|
i have the same problem
dgvPhysioSession.Rows[rowIndex].Cells["Diagnosis"].Value
it returns null
|
|
|
|
|
Humm this is a puzzler im settings from a .txt file which looks like this
//This is the directory which your downloaded files will be stored in
DownloadFolder = /mnt/md1/public/Downloads
//The telnet user usualy root
TelnetUser = root
//The telnet password
TelnetPassword = root
//The IP of your NAS eg 192.168.2.2
TelnetIP = 192.168.2.2
I want to convert these values into strings eg TelnetIP = 192.168.2.2 so they can be reused on multiple forms . So ive got them importing with a StreamReader below
private void LoadSettings()
{
StreamReader Settings = new StreamReader("Settings.txt");
string line;
while ((line = Settings.ReadLine()) != null)
{
if (line.StartsWith("/"))
{
}
else
{
string[] splitArray = line.Split(new char[] { '=' });
MessageBox.Show(splitArray[0]);
}
}
}
So in this case splitArray[0] gives DownloadFolder and splitArray[1] gives /mnt/md1/public/Downloads perfect but how do i join them back togeather to give
DownloadFolder = /mnt/md1/public/Downloads
And also im getteng blank lines coming through as settings else if (line.StartsWith("/r/n")) or \r\n dosnt seem to catch them
any ideas ? thanks
|
|
|
|
|
I do not know if this will work but I know when I use string you have to be careful of slashes and so on so for one you could try:
private void LoadSettings()
{
StreamReader Settings = new StreamReader("Settings.txt");
string line;
while ((line = Settings.ReadLine()) != null)
{
if (line.StartsWith(@"/"))
{
}
else
{
string[] splitArray = line.Split(new char[] { '=' });
MessageBox.Show(splitArray[0]);
}
}
}
The at symbol will ensure it is read as string....
as for getting the strings back together you could use a string builder or just add the values together
string var = (splitArray[0] + " = " + splitArray[1]);
I am not sure if that is the best way to do it. Hope that helps.
|
|
|
|
|
Hum im getting System.IndexOutOfRangeException was unhandled
Message="Index was outside the bounds of the array."
i think it might have something to do with splitArray[0] being empty , The line brakes seem to have gotten through
|
|
|
|
|
The MSDN on 'is' operator says ...the provided object can be cast to the provided type without causing an exception to be thrown. Suppose I have the following code:
object x = FunctionThatReturnsAnInteger();
if(x is decimal)
Console.WriteLine("Hello world");
The above condition is never true because x is of type integer, not decimal, but - int can be cast to decimal without an exception being thrown - so why does it not work?
More directly to my problem - what is the fastest (in runtime) way to check, if a variable (of type 'object', in general) can be cast to decimal? I can obviously try this in a try-catch block, but I wonder if there are ways that perform better.
Thanks for sugegstions, H.
|
|
|
|
|
These are integral types, is only works for classes. This should not compile. The is operator WILL work with a class structure.
class Base
class Derived1 : Base
Derived1 n;
if ( n is Base )
{
// this will work
}
Member 1033907 wrote: what is the fastest (in runtime) way to check, if a variable (of type 'object', in general) can be cast to decimal?
I suspect you need your try/catch block. You also have the cost of boxing to contend with. You could try calling ToString on the object and then decimal.TryParse, that should work for things like int.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Thanks for your reply.
Christian Graus wrote: This should not compile.
I compiles fine, 'is' works with structures as well. And besides - 'x' in the previous example is of type 'object', so the compiler has no way of knowing it is going to contain an integer.
Christian Graus wrote: You could try calling ToString on the object and then decimal.TryParse, that should work for things like int.
String parsing seems to me like the slowest possible approach. I guess I'll go with the try/catch, which is guaranteed to work, unless someone comes with something faster.
|
|
|
|