GetUID.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.Configuration;
- using System.Data.SqlClient;
- namespace User
- {
- public class GetUID
- {
- int uid;
- SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CartConnectionString"].ConnectionString);
- /// <summary>
- ///
- /// </summary>
- /// <param name="name"></param>
- /// <returns></returns>
- public int GetUIDs(String name) {
- String T_name = name;
- String sql = "select UID from U_Info where UserName='" + T_name + "'";
- SqlCommand cmd = new SqlCommand(sql, conn);
- try
- {
- conn.Open();
- SqlDataReader MyReader = cmd.ExecuteReader();
- if (MyReader.Read())
- {
- uid = MyReader.GetInt32(0);
- }
- }
- catch (Exception ex)
- {
- throw (ex);
- }
- finally {
- conn.Close();
- }
- return uid;
- }
- }
- }