|
List lstusers = new List();
lstusers = AMSManagement.GetAllUsers();
var lnquser = from u in lstusers
show error here plz help me!!!
-------------
where u.User_ID == int.Parse(Session["UserID"].ToString()) && u.Pass_word == txtopwd.Text.Trim()
select u;
--------------------
if (lnquser.ToList().Count > 0)
{
users u = new users();
u.User_ID = int.Parse(Session["UserID"].ToString());
u.Pass_word = txtcnpwd.Text.Trim();
AMSManagement.Changepassword(u);
lblmsg.Text = "Password Changed Successfully!";
}
|
|
|
|
|
Are you very sure the session contains UserID?
Try with the following code:
where u.User_ID == int.Parse(Session["UserID"]==null? "0":Session["UserID"].ToString()) && u.Pass_word == txtopwd.Text.Trim()
|
|
|
|
|
List<users> lstusers = new List<users>();
lstusers = AMSManagement.GetAllUsers();
var lnquser = from u in lstusers
where u.User_ID == int.Parse(Session["UserID"] == null ? "0" : Session["UserID"].ToString())&& u.Pass_word==txtopwd.Text.Trim()
select u;
if (lnquser.ToList().Count > 0)
{
users u = new users();
u.User_ID = int.Parse(Session["UserID"].ToString());
u.Pass_word = txtcnpwd.Text.Trim();
AMSManagement.Changepassword(u);
lblmsg.Text = "Password Changed Successfully!";
}
else
{
lblmsg.Text = "plz enter valid old password!";
}
when i change code as your view then it execute else part
|
|
|
|
|
Could you please debug and check the value of Session["UserID"]
I think Session["UserID"] is not initiated.
|
|
|
|
|
|
Could you please post the code where are you setting the value of Session["UserID"]?
|
|
|
|
|
public int User_ID { set; get; }
public string UserID { set; get; }
public string Pass_word { set; get; }
public string UserType { set; get; }
|
|
|
|
|
you need to check the value of the UserID
string UserID = Session["UserID"].ToString();
I would put this before the LinQ statement and put a breakpoint on it, step over that line and then see what if any value UserID holds. So change your code to
string UserID = Session["UserID"].ToString();
var Inquser = from u in lstusers where u.User_ID == int.Parse(Session["UserID"].ToString()) && u.Pass_word == txtopwd.Text.Trim();
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
Try this instead:
int userId;
object sessionValue = Session["UserID"];
string session = string.Empty;
string password = txtopwd.Text;
if (session != null && int.TryParse(session.ToString(), out userId) && !string.IsNullOrWhitespace(password))
{
var lnguser = from u in lstusers where u.User_ID == userId && u.Pass_word == password.Trim();
}
|
|
|
|
|
|
Sorry, but that makes no sense at all.
Use the best guess
|
|
|
|
|
정성만 wrote: Barcode image binary data must be sent to the printer. Printers do not know how to decode "random" image-formats, and can't handle that kind of data. There's a printer-driver that translates it to the printer-language of that specific brand of printer. Create a <a href="http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx">PrintDocument</a>[<a href="http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx" target="_blank" title="New Window">^</a>] and implement the "PrintPage" event. It has a nice Graphics object that you can draw your image on.
Also, you'd get more useful replies if you added your printing-code to the post. It often shows the intention of the programmer better than a picture can.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
why is my query wrong at FROM ?
i want to connect two tables so i can get some specific data but c# appear error.
try
{
//Set the command string
string Cmd = "SELECT * FROM Robberies_Table JOIN Branches_Table ON Robberies_Table.BranchCode =Branches_Table.BranchCode ;";
//create new new connection to the database
OleDbConnection conn = new OleDbConnection(ConnectionString);
//create new data adapter
OleDbDataAdapter Adapter = new OleDbDataAdapter(Cmd, conn);
//create new command builder
OleDbCommandBuilder CmdBuilder = new OleDbCommandBuilder(Adapter);
dTable = new DataTable();
Adapter.Fill(dTable);
conn.Close();
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
//return the search results on a datatable
return dTable;
}
|
|
|
|
|
Your SQL query has a semi-colon in there. Remove it.
|
|
|
|
|
i remove inner semi-colon but the query has error again at from field .
string Cmd = "SELECT * FROM Robberies_Table JOIN Branches_Table ON Robberies_Table.BranchCode =Branches_Table.BranchCode ";
|
|
|
|
|
A couple of things:
- What error does it come up with? Give us a fighting chance here.
- What happens if you run this query directly against your database?
|
|
|
|
|
THE QUERY RUN SUCCESSFULLY AND IS IN THIS FORMAT:
SELECT Robberies_Table.BankName, Robberies_Table.Region, Robberies_Table.BranchCode, Robberies_Table.[Date], Robberies_Table.Ammount,
Robberies_Table.Description, Robberies_Table.Robbery_ID, Robberies_Table.[Year], Branches_Table.BranchName
FROM (Robberies_Table INNER JOIN
Branches_Table ON Robberies_Table.BranchCode = Branches_Table.BranchCode)
IN C# THE QUERY I WRITE IS LIKE THIS :
string Cmd = "SELECT * FROM (Robberies_Table INNER JOIN Branches_Table ON Robberies_Table.BranchCode = Branches_Table.BranchCode);";
AND WHEN I RUN THE PROGRAM NOW ONLY THE RECORD IS UNDER THE BRANCHNAME IT APPEAR IN SCREEN THE DATA OF ROBBERIES TABLE DON'T SHOW ME
modified 2-Apr-13 17:44pm.
|
|
|
|
|
So use that query in your code.
|
|
|
|
|
IN C# THE QUERY I WRITE IS LIKE THIS :
string Cmd = "SELECT * FROM (Robberies_Table INNER JOIN Branches_Table ON Robberies_Table.BranchCode = Branches_Table.BranchCode);";
AND WHEN I RUN THE PROGRAM NOW ONLY THE RECORD IS UNDER THE BRANCHNAME IT APPEAR IN SCREEN THE DATA OF ROBBERIES TABLE DON'T SHOW ME
IF I WRITE THE SAME THAT IS IN MY DATABASE QUERY C# SHOW ME MY CRYSTAL REPORT EMPTY SO I WRITE AS ABOVE AND HAS THE ABOVE ERROR
DIDN'T SHOW ANYTHING:
------------------------
string Cmd = "SELECT Robberies_Table.BankName, Robberies_Table.Region, Robberies_Table.BranchCode, Robberies_Table.[Date], Robberies_Table.Ammount,Robberies_Table.Description, Robberies_Table.Robbery_ID, Robberies_Table.[Year], Branches_Table.BranchName FROM (Robberies_Table INNER JOIN Branches_Table ON Robberies_Table.BranchCode = Branches_Table.BranchCode);";
|
|
|
|
|
I don't know how many different ways I can put this, but try running the same query that you issue in your C# code in the SQL table. You can't run different queries and then expect them to be the same.
|
|
|
|
|
MY DATABASE IS ACCESS NOT SQL AND I OBSERVE THAT HAS MANY DIFFERENCES IN THE WAY YOU WRITE THE QUERY.
BUT ITS OK I WILL TRY MORE AND I WILL FIND THE SOLUTION ANYWAY...
THANK YOU
|
|
|
|
|
Please don't SHOUT. It's not polite.
/ravi
|
|
|
|
|
|
No worries!
/ravi
|
|
|
|
|
Would you plaese remove the * and write the columns that you want to access after joining both the table
like--
select column1,column2 from (table1 JOIN table2 where.....)
|
|
|
|