我正在使用访问表
我正在使用包含这些公共功能的 oleDBManager:
/// <summary>
/// Excecutes an SELECT query and returns the data.
/// </summary>
/// <param name="query">the query string</param>
/// <returns>returns an DataTable instance with the recived data from the selection query.</returns>
public DataTable ExcecuteRead(string query) {
this.link.Open();
// ---
this.dataAdapter = new OleDbDataAdapter(query, this.link);
// ---
this.dataTable = new DataTable();
this.dataAdapter.Fill(this.dataTable);
// ---
this.link.Close();
// ---
return this.dataTable;
}
/// <summary>
/// Returns an HTML table code, with all the rows and the values of the results.
/// </summary>
/// <param name="query">the query string</param>
/// <returns>returns an HTML code as a string</returns>
public string ExcecuteTableRead(string query)
{
string output = "<table border=\"1\">";
// ---
this.dataTable = this.ExcecuteRead(query);
// ---
foreach (DataRow row in this.dataTable.Rows)
{
output += "<tr>";
// ---
foreach (object obj in row.ItemArray)
{
output += "<td>" + obj.ToString() + "</td>";
}
// ---
output += "</tr>";
}
// ---
output += "</table>";
// ---
return output;
}
/// <summary>
/// Returns an HTML table code, with all the rows and the values of the results.
/// </summary>
/// <param name="query">the query string</param>
/// <param name="max">the maximum number of rows to show</param>
/// <returns>returns an HTML code as a string</returns>
public string ExcecuteTableRead(string query, int max)
{
int i = 0;
string output = "<table border=\"1\">";
// ---
this.dataTable = this.ExcecuteRead(query);
// ---
foreach (DataRow row in this.dataTable.Rows)
{
if (i < max)
{
output += "<tr>";
// ---
foreach (object obj in row.ItemArray)
{
output += "<td>" + obj.ToString() + "</td>";
}
// ---
output += "</tr>";
}
i++;
}
// ---
output += "</table>";
// ---
return output;
}
在我的“用户”表中,每个用户都有一个“用户 ID”、“用户名”、“密码”和“登录名”。我的问题是,当用户登录时(我有用户名和密码),我怎样才能得到他的“登录”列的值?如果我可以将它设置为一个 int 会更好(如果重要的话,我已经将“登录”列设置为从“文本”访问“数字”。
编辑:我想做的是更新用户登录的次数。如果有更好的方法,请告诉我。