|
Where are you seeing these characters? In the debugger?
If yes, do a Debug.WriteLine, and you'll see that those characters aren't really there
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
SqlCommand cmd = new SqlCommand("Select * FROM tbl_Loging where User Name=@user_name and Password=@password", con);
cmd.Parameters.AddWithValue("@user_name", text_User_Name.Text);
cmd.Parameters.AddWithValue("@password", text_Password.Text);
con.Open();
SqlDataAdapter adapt = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adapt.Fill(ds);
con.Close();
Error : An expression of non-boolean type specified in a context where a condition is expected near 'Name"
P David
|
|
|
|
|
"User Name" is not a normal column-name, and the space in the name will muck up the command. If that is how the column is actually named, you should add brackets like below;
where [User Name]=@user_name
..and complain loudly about the person who designed the database
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Column names cannot contain spaces. Either rename your column to UserName , or wrap the column name in square brackets:
Select * FROM tbl_Loging where [User Name]=@user_name and Password=@password
However, you are currently storing your passwords in plain text. That is an extremely bad idea. You should only ever store a salted hash of the password, using a unique salt per record.
Secure Password Authentication Explained Simply[^]
Salted Password Hashing - Doing it Right[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
Message Closed
modified 6-Apr-17 12:31pm.
|
|
|
|
|
No, the column-name was the problem. The extra brackets are the solution to that problem.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi,
I have to get list of subdirectoris in parent folder ("A_ParentDir") which have names in format "vX.XX" where X is numeric.
Example : I have folder A_ParentDir which contains list of directories as below :
v3.20
v4.56
v8.1
v5.60a
v6.00v6.00
so I should have only :
v3.20
v4.56
I tried as below but I have also the last one in result
v3.20
v4.56
v6.00v6.00 // this shouldn't be
string strreg = @"v\d{1}\.{1}\d{2}$";
arrVersionsDirectories = Directory.GetDirectories(A_ParentDir)
.Where(path => Regex.IsMatch(path, strreg))
.ToList();
thank for help
|
|
|
|
|
You need to add a "start of string" indicator to your regex:
string strreg = @"^v\d{1}\.{1}\d{2}$";
But a simpler to read version would be:
string strreg = @"^v\d\.\d\d$";
If you are going to use Regexes, then I'd suggest you get a copy of Expresso[^] - it's free, and it examines and generates Regular expressions.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
|
Nope - see my other reply!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Ignore the previous answer!
I forgot the folder path was there...
Best way is to do this:
string strreg = @"^v\d\.\d\d{2}$";
arrVersionsDirectories = Directory.GetDirectories(A_ParentDir)
.Where(path => Regex.IsMatch(Path.GetFileName(path), strreg))
.ToList()
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Hi, I am coding two .cs files into one dll but Visual Studio 2012 sends the following error message:
The name 'Beeper' does not exist in the current context.
The first file codes like this:
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Windows.Forms;
namespace Hum
{
public class Singer
{
public void Beeper(long frequency, int msDuration, long volume)
{
}
}
}
When I do the function call in the second .cs file:
Singer cacophony = new Singer();
int Duration = 300000;
ThreadStart Wfrequency = new ThreadStart(Beeper(nw, Duration, 16383));
Thread childThreadW = new Thread(Wfrequency);
childThreadW.Start();
It gives the error.
I know I am missing something very basic.
Thanks for the help.
|
|
|
|
|
Beeper is a member function of Singer (the class)... Calling it like Beeper alone will only work when you are in the context of Singer (from other members for instance).
If you are out of that context you have to tell the compiler the new/actual context... in your case cacophony ...
So the code should be like this:
new ThreadStart(cacophony.Beeper(...));
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
Ok, now the error is:
Method name expected.
Any ideas?
|
|
|
|
|
|
Sorry, but please walk me through it.
The example and my code look identical to me.
|
|
|
|
|
You really need to understand the basics of c# before you try anything half-way complicated. We can't solve every basic problem you have. Get a book on c# and learn the fundamentals so you can solve these issues yourself, a forum is not a good place to learn something from scratch.
|
|
|
|
|
Please show the code and the error message, we cannot see your screen.
|
|
|
|
|
This exact line of code is where the error occurs:
ThreadStart Wfrequency = new ThreadStart(cacophony.Beeper((int)nw, Duration, 16383));
Specifically the ThreadStart() function.
The error is:
Method name expected.
|
|
|
|
|
As shown on the link that Peter already gave you, the delegate creator needs the method name only. So your code should be:
ThreadStart Wfrequency = new ThreadStart(cacophony.Beeper);
See also Creating Threads and Passing Data at Start Time[^].
|
|
|
|
|
Ok, but as you may see. The Beeper(); Function inputs 3 parameters (frequency, Duration and volume).
The
ThreadStart(cacophony.Beeper); does not pass these parameters or am I missing something?
|
|
|
|
|
Member 12244972 wrote: or am I missing something? Yes, what you are creating here is a delegate, not an immediate call to the beeper method. You need to spend more time reading the links you have been given to understand how delegates are used. See the tutorials on Events and Delegates at C# Tutorials (C#)[^].
|
|
|
|
|
Ok, removed the
ThreadStart();
and implemented a lambda...
Thread childThreadW = new Thread(unused => cacophony.Beeper((int)nw, Duration, 16383));
and my code builds fine now.
Thank you all!
|
|
|
|
|