public string GenerateKey() { int data = 0; string id = ""; string str = "select billno from tblEditBill"; //table name tblEditBill OdbcCommand cmd; cmd = new OdbcCommand(str, conn); OdbcDataReader dr; dr = cmd.ExecuteReader(); while (dr.Read() != false) { data = Convert.ToInt32(dr.GetString(0)); } try { int newid = Convert.ToInt32(data); //Int32.Parse(data); id = Convert.ToString(newid + 1); } catch (Exception ex) { MessageBox.Show(ex.Message + ex.Source); } return id.ToString(); }
protected string GetInteger(string s) { string str = s; string newStr = "";// string newStr = string.Empty; for (int i = 0; i < str.Length; i++) { // here i will check for the ascii value to match with 0123456789 then it will add to new string if (Convert.ToInt32(str[i]) > 47 && Convert.ToInt32(str[i]) < 58) { newStr += str[i]; } } // now new gentrated string will be returned return newStr; }
data = Convert.ToInt32(Regex.Match(dr.GetString(0), "\d+").Value);
string id = "";
string id = string.Empty;
string str = "select...";
OdbcDataReader dr; dr = cmd.ExecuteReader();
OdbcDataReader dr = cmd.ExecuteReader();
while (dr.Read() != false)
while (dr.Read())...
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)