c#怎么读取SQLserver中返回的单个数据

我要怎样做才能获取到这个Jid?求大神啊!!!

                            
       public static SqlConnection conn;
        public static string ConStr;//数据库连接字符串
        public static string ComStr="select Jid from 表名称 ";//数据库字段查询字符串
        public string GetTop()
        {string Str;//获取到的字符串
        conn = new SqlConnection(ConStr);
        conn.Open();
        SqlCommand cmd = new SqlCommand(ComStr, conn);
        Str=cmd.ExecuteScalar().ToString();
        cmd.Dispose();
        Con_Close();
        return Str;}

温馨提示:答案为网友推荐,仅供参考
相似回答