SQL how to get a value from a cell in an access table

xucaixi

New Member
I'm using access tablei'm using this oleDBManager that includes these public fuctions:\[code\]/// <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;}\[/code\]in my "users" table, i have a "userid", "username", "password" and "logins" for each user.my question is, when the user logins (i have the username and the password), how can i get the value of his 'logins' column?would be even better if i could set it into an int (if it matters, i've set the "logins" column in access to 'number' from 'text'.thanks.edit: what i'm trying to do is to update the number of times the user has loged in. if there's a better way, please tell me.answer:So, although no one answered me, i've managed to learn it myself:here is the whole part of the code (username is the name of the user and also a string of it with the same name, logins is the column, users is the table)\[code\]string logins = db.ExcecuteTableRead("SELECT logins FROM users WHERE username='" + username + "'");logins = logins.Substring(21, 20);logins = Regex.Match(logins, @"\d+").Value;int loginsInt = Int32.Parse(logins) + 1;int a = db.ExecuteQuery("UPDATE users SET logins='" + loginsInt.ToString() + "' WHERE username='" + username + "'");\[/code\]
 
Back
Top