How to return application id using database in c#

 private string GetApplicationNo(string ApplicationID)
        {
            string returnval = string.Empty;
            try
            {
                query = @"select ApplicationNo from ApplicationMSt where ApplicationID=@ApplicationID";

                using (SqlCommand cmd = new SqlCommand(query, ObjCon))
                {
                    cmd.Parameters.AddWithValue("@ApplicationID", ApplicationID);

                    if (ObjCon.State != ConnectionState.Open)
                        ObjCon.Open();

                    object obj = cmd.ExecuteScalar();

                    if (obj != null)
                    {
                        returnval = obj.ToString();
                    }

                    if (ObjCon.State != ConnectionState.Closed)
                        ObjCon.Close();
                }
            }
            catch (Exception ex)
            {
                lblApplDocError.Text = cnclss.SendExcepToDB(pageName, MethodBase.GetCurrentMethod().Name.ToString(), HttpContext.Current.Request.Url.ToString(), ex);
            }
            finally
            {
                if (ObjCon.State != ConnectionState.Closed)
                    ObjCon.Close();
            }
            return returnval;
        }

Comments

Post a Comment

Popular posts from this blog

String Program in C#

CSV using XmlNode

Controller_Model. cs