• 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);

  • 相关阅读:
    poj 1182食物链
    几何原本查询程序1.0
    code forces 548C:Mike and frog
    CC2530串口通信
    CC2530定时器的应用
    CC2530应用——按键控制灯光状态变化
    步入LTE、多址技术
    定时器之基于模模式的间隔定时
    CC2530定时器
    配置路由器(1)
  • 原文地址:https://www.cnblogs.com/llguanli/p/7097223.html
Copyright © 2020-2023  润新知