Hai
Solution 1 is work fine,if u want ur coding way try this
private void btnOk_Click(object sender, EventArgs e)
{
connect.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\XX\Documents\Visual Studio 2013\Projects\Access\Database.accdb;Persist Security Info=False";
DataTable dt1 = new DataTable();
string strcmd1 = "";
OleDbDataAdapter cmd1 = new OleDbDataAdapter;
string UserName = txtUserName.Text;
string PassWord = txtPassWord.Text;
connect.Open();
strcmd1 = ("SELECT UserName, PassWord FROM TAdminPW WHERE UserName='" & txtUserName.Text.Trim() & "' and Password='" & txtPassWord.Text.Trim() & "'");
cmd1 = new OleDbDataAdapter(new OleDbCommand(strcmd1));
cmd1.SelectCommand.Connection = connect;
cmd1.Fill(dt1)
if ((dt1.Rows.Count > 0)) {
} else {
}
}
}
}
Regards
Aravind