| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1394 人关注过本帖
标题:初学C#,请教如何变量取值的问题
取消只看楼主 加入收藏
kent73
Rank: 1
等 级:新手上路
帖 子:61
专家分:5
注 册:2009-3-4
结帖率:46.67%
收藏
已结贴  问题点数:20 回复次数:2 
初学C#,请教如何变量取值的问题
之前通过如下代码能成功执行
string sql = "select count(*) as result from table where  FBarCode='" + barcode + "' and FCategory='" + lbie + "'";
int res = SQLSERVERUtil.GetRecordCount(sql);
if (res < 1)    //数据不存在
{
   labNotice.Text = "该数据不存在";
   temp_del = false;
}

那么我用下面的代码,怎么把ID赋值给变量
string sql = "select id from table where  FBarCode='" + barcode + "' and FCategory='" + lbie + "'and FUpdate=1";

谢谢了
搜索更多相关主题的帖子: barcode result false count where 
2015-07-27 10:04
kent73
Rank: 1
等 级:新手上路
帖 子:61
专家分:5
注 册:2009-3-4
收藏
得分:0 
回复 2楼 Maick
这是一段现有的程序,我需要在程序中间加入一段代码。
能帮我改改吗
2015-07-27 11:59
kent73
Rank: 1
等 级:新手上路
帖 子:61
专家分:5
注 册:2009-3-4
收藏
得分:0 
回复 4楼 Maick
SQLSERVERUtil完整代码是这样的,能帮我结合了改改吗?
class SQLSERVERUtil
    {

        private static SoundPlayer simpleSound;
        public static string errorpath = "\\Flash Disk\\error.wav";
        public static string rightpath = "\\Flash Disk\\right.wav";

        private static SqlConnection conn = GetConnection();
        private static SqlCommand cmd = null;
        public static SqlConnection GetConnection()
        {
            string connectionString = "";
            try
            {
                SQLSERVERconfig serverConfig = FileUtil.GetConfiguration();
                if (serverConfig.server!=null)
                {
                    connectionString = "Data Source=" + MainForm.userform.option.ReadString("Info", "IP", "") ;
                }
                if (serverConfig.database!=null)
                {
                    connectionString = connectionString + ";initial catalog=" + MainForm.userform.option.ReadString("Info", "DataName", "");
                }
                if (serverConfig.uid != null)
                {
                    connectionString = connectionString + ";UID=" + MainForm.userform.option.ReadString("Info", "User", "");
                }
                if (serverConfig.pwd != null)
                {
                    connectionString = connectionString + ";PWD=" + MainForm.userform.option.ReadString("Info", "Password", "");
                }
               
            }
            catch (System.Exception ex)
            {
                throw new System.Exception(ex.Message);
            }
            SqlConnection connection = null;
            try
            {
                connection = new SqlConnection(connectionString);
            }
            catch (System.Exception ex)
            {
                throw new System.Exception(ex.Message);
            }

            return connection;
        }
2015-07-27 14:13
快速回复:初学C#,请教如何变量取值的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026965 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved