zoukankan      html  css  js  c++  java
  • c# 查询sql 返回多个參数

    1.依据须要查询mysql 语句,返回三个须要的參数,不是数据集

    2.编写函数例如以下:

        public static void GetParas(string 条件1, out string 返回值1, out string 返回值2, out string 返回值3)
            {
                返回值1= string.Empty;
                返回值2= string.Empty;
                返回值3= string.Empty;


              
                string strSQL = string.Format("Select * from 表 where 字段1= '{0}' limit 1", 条件1);

         //运行sql语句

                DataTable dt = ds.Tables[0];
                if (dt != null && dt.Rows.Count == 1)
                {
                    object obj = dt.Rows[0][返回值1"];
                    if (obj != null && !(obj is DBNull))
                    {
                        返回值1= Convert.ToString(obj).Replace(" ", "");
                    }
                    obj = dt.Rows[0]["返回值2"];
                    if (obj != null && !(obj is DBNull))
                    {
                        返回值2= Convert.ToString(obj);
                    }
                    obj = dt.Rows[0]["返回值3"];
                    if (obj != null && !(obj is DBNull))
                    {
                        返回值3= Convert.ToString(obj);
                    }
                }
            }



    3.通过上述sql运行,就查询相应的三个返回值。

    4.调用函数例如以下

     string 返回值1= string.Empty;
     string 返回值2= string.Empty;
     string 返回值3= string.Empty;

     GetParas(查询条件1, out 返回值1, out 返回值2,, out 返回值3);

  • 相关阅读:
    近期计划安排
    线段树+离散化+染色
    矩阵快速幂(共轭函数两种递推式)
    树状数组求区间最值和单点更新
    矩阵快速幂(共轭函数)
    树状数组之区间更新与查询
    Python List min()方法
    Python List max()方法
    Python List len()方法
    Python List cmp()方法
  • 原文地址:https://www.cnblogs.com/llguanli/p/7097223.html
Copyright © 2011-2022 走看看