goods.cs
资源名称:yjal.rar [点击查看]
上传用户:shjujing
上传日期:2022-07-28
资源大小:11244k
文件大小:1k
源码类别:
Email客户端
开发平台:
Visual C++
- /********************************************************************************
- ** 作者:ebDoing
- ** 创始时间: 2008-10-22
- ** 描述:
- ** 主要用于检索商品信息,…
- ** 表:
- *********************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Data.SqlClient;
- using System.Configuration;
- namespace SearchGoods
- {
- public class goods
- {
- int gid;
- SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CartConnectionString"].ConnectionString);
- /// <summary>
- ///
- /// </summary>
- /// <param name="GoodsName"></param>
- /// <returns></returns>
- public int GetGoodsID(String GoodsName) {
- String T_name = GoodsName;
- String sql = "select * from tb_GoodsInfo where GoodsName='" + T_name + "'";
- SqlCommand cmd = new SqlCommand(sql, conn);
- try
- {
- conn.Open();
- SqlDataReader MyReader = cmd.ExecuteReader();
- if (MyReader.Read())
- {
- gid = MyReader.GetInt32(0);
- }
- }
- catch (Exception ex)
- {
- throw (ex);
- }
- finally {
- conn.Close();
- }
- return gid;
- }
- }
- }