c# 读取数据库得到字符串

 public string GetProductType(string connectionString, string barCode)
        {
            string productType;
            SqlConnection conn = new SqlConnection(connectionString);
            conn.Open();
            //MessageBox.Show("连接成功");
            string sqlCmd = "select 产品型号 from ProName where 壳体编号 = '"+ barCode + "'";

            SqlCommand command = new SqlCommand(sqlCmd, conn);
            SqlDataReader read = command.ExecuteReader();
            if (read.Read())
            {
                productType = read["产品型号"].ToString();
                conn.Close();
                return productType;
            }

}

posted @ 2013-07-19 14:03  佳序  阅读(728)  评论(0编辑  收藏  举报