public string generateFNo() { String str = "SELECT Max(fdk_No) From tblFeedback"; string fNo = null; SqlCommand con = new SqlCommand(str, cn); cn.Open(); if (con.ExecuteScalar().Equals(DBNull.Value)) { fNo = "F01"; } else { fNo = con.ExecuteScalar(); //Display the new fdkno (by get the last fdkno from db)+1 string[] splitCode = Strings.Split(fNo, "F", 2); fNo = "F0" + ((Convert.ToInt32(splitCode[1])) + 1).ToString(); } cn.Close(); } }
Quote:fNo = con.ExecuteScalar();
fNo = (string) con.ExecuteScalar();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)