Hello,
i have encountered with a problem in one of methods comparing string from database to the string named pword that i initialized from textbox. Can anyone know the easiest for begginer to fix it? I would be very very greatful.
SqlConnection myConnection = new SqlConnection();
myConnection.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=D:\\Studijos\\c#\\KursinisDarbas\\BazineAplikacija\\BazineAplikacija\\DuomenuBaze.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
DataSet myDataSet = new DataSet();
string sql = "SELECT *From tblWorkers";
SqlDataAdapter myAdapter = new SqlDataAdapter(sql, myConnection);
myAdapter.Fill(myDataSet, "Workers");
myConnection.Open();
int MaxRows = myDataSet.Tables["Workers"].Rows.Count;
bool permition = false;
for (int i = 0; i < MaxRows; i++)
{
DataRow myRow = myDataSet.Tables["Workers"].Rows[i];
MessageBox.Show(myRow.ItemArray.GetValue(4).ToString());
if (Convert.ToInt32(myRow.ItemArray.GetValue(0).ToString()) == ID)
{
if (pword == myRow.ItemArray.GetValue(4).ToString())
{
permition = true;
}
else
{
MessageBox.Show("Wrong password");
}
}
}
myConnection.Close();
return permition;