A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.
Hi VAer,
You can use System.Data.OleDb Namespace to read and write data from access database. And please refer to this sample:
private void button1_Click(object sender, EventArgs e)
{
if (isInDataBase("aa"))
{
MessageBox.Show("yes");
}
else
{
MessageBox.Show("No");
}
}
public bool isInDataBase(string username)
{
string connString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\data.accdb;Jet OLEDB:Database Password=Pa$$word123;";
using (OleDbConnection connection = new OleDbConnection(connString))
{
OleDbCommand command = new OleDbCommand("SELECT username FROM [Table]", connection);
connection.Open();
OleDbDataReader reader = command.ExecuteReader();
while (reader.Read())
{
if(reader[0].ToString() == username) return true;
}
}
return false;
}
Best Regards, Dylan
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our *
*documentation* to enable e-mail notifications if you want to receive the related email notification for this thread.**