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
Farrukh Javeid
NA
38
0
Inter-Class Communication
Mar 19 2010 5:02 PM
Hello folks,
I am having a problem in my program that has apparently no reason to show itself but somehow it is. It actually comes when i run the program using F5 key, the program doesn't work properly while I execute it step by step using F11 key, it works perfectly fine.
Well, here is my problem.
frm_Login obj = new frm_Login();
username = obj.getUsername();
lbl_Welcome.Text = "Welcome "+username;
This given code is placed in another class but when i call it doesn't work.
The code of the function
getUsername()
is as given below
public string getUsername()
{
SqlConnection con = new SqlConnection(Properties.Settings.Default.ConnectionStr);
string getCurrentUsername = "select User_Name from tblSecUsers where User_ID = '"+tbx_UserID.Text+"'";
con.Open();
SqlCommand cmd = new SqlCommand(getCurrentUsername, con);
SqlDataReader reader = null;
reader = cmd.ExecuteReader();
while (reader.Read())
{
username = reader["User_Name"].ToString();
}
con.Close();
return username;
}
Urgent help required fellows.
Regards.
Reply
Answers (
8
)
i want to enter the elements into an array when executing the program.how?
How do I: Pass a DataTable from a Class to the Main program?