TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
praveenreddy
NA
2
0
Specified cast is not valid
Apr 26 2005 3:33 AM
I got the following error message "Specified cast is not valid" Description: An unhandled exception occured during the execution of the current webrequest.Please review the stack trace for more information about the error and where it originates in the code. .NET Framework info: "Microsoft.NET\Framework\v1.1.4322" Message = Specified cast is not valid. Method = Session_Start StackTrace = at Global.Session_Start(Object sender, EventArgs e) Global.Session_Start method is here: protected void Session_Start(Object sender, EventArgs e) { // LOG THE NEW USER try { WindowsPrincipal principal = (WindowsPrincipal) Thread.CurrentPrincipal; Session["UserId"] = principal.Identity.Name ; // IF BOGUS USER FROM DEBUG OR SOMETHING THEN IGNORE if (Session["UserId"].ToString().Length < 3) return; Application.Lock(); Application["CurrentUsers"] = (int)Application["CurrentUsers"] + 1; Application.UnLock(); string sqlCmdStr = " Insert into UserLog (UserName, LoginTime) VALUES('" + Session["UserId"] +"', '" + DateTime.Now.ToString() + "')" ; SqlConnection conn = SQLDbUtils.Connection(); conn.Open(); SqlCommand cmd = new SqlCommand(sqlCmdStr, conn); cmd.ExecuteNonQuery(); //Code to fetch user preference data from the database sqlCmdStr="Select * from UserPreferences where UserName='"+Session["UserId"].ToString() + "'"; SqlDataAdapter da = new SqlDataAdapter(sqlCmdStr,conn); DataSet tempdb= new DataSet(); da.Fill(tempdb,"UserPreferences"); } conn.Close(); } catch(Exception ex) { WebPageUtils.EventLogger(ex); }
Reply
Answers (
0
)
How to set Excel spreadsheet column type to Text thru program
Overflow Exception