Reputation: 3451
I am just starting to learn C# and this is my very first request for help.
I have written a log-in script which has the usual "username" and "password" fields plus submit button.
The script queries a MySQL data table and if the username and password match closes the log-in window and opens a detail window.
What I am trying to do is use two of the fields from the query and pass the content to the detail window for display. This is the code so far:
MySqlCommand SelectCommand = new MySqlCommand(
"SELECT clientID, login, pass, name_f,
name_l FROM FIDS_members WHERE login = '" +
this.username_txt.Text + "' AND pass = '" +
this.pass_txt.Text + "';", myConn);
MySqlDataReader myReader;
myConn.Open();
myReader = SelectCommand.ExecuteReader();
int count = 0;
while (myReader.Read())
{
count = count + 1;
}
if (count == 1)
{
string name_f = myReader.GetString("name_f").ToString();
name_f_txt = name_f;
this.Hide();
Welcome f2 = new Welcome(name_f.Text);
f2.ShowDialog();
}
else
MessageBox.Show("The username or password are incorrect, please try again...");
// Clear login feilds
username_txt.Text = String.Empty;
pass_txt.Text = String.Empty;
The error I am getting is:
"string does not contain a definition for "Text".
I am aware that I may not be doing this correctly but if someone could please provide some pointers it would be very helpful.
Upvotes: 0
Views: 239
Reputation: 68400
The error is probably because this line
Welcome f2 = new Welcome(name_f.Text);
Change it by
Welcome f2 = new Welcome(name_f);
name_f
is a string according your code and it seems you're using it as a TextBox
Upvotes: 1