我使用的訪問表SQL如何從一個單元格的值在訪問表
我使用這個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;
}
在我的「用戶「表,我有一個」用戶名「,」用戶名「,」密碼「和」登錄「爲每個用戶。 我的問題是,當用戶登錄(我有用戶名和密碼)時,如何獲取他的「登錄」列的值? 如果我可以將它設置爲一個int,會更好(如果它很重要,我已設置「登錄」列從「文本」中訪問'數字')
編輯:我正在嘗試要做的是更新的時間在用戶登錄次數。如果有一個更好的辦法,請告訴我。
所以基本上我想,該SQL語法應該是 '「SELECT FROM用戶登錄WHERE用戶名='」 +用戶名+「 '''' 但問題是,當我使用ExcecuteRead()fu它返回一個DataTable類型,而不是一個int或一個字符串。 有幫助嗎? –