超市前台结算系统链接数据库,增删改赋值给前台
class SQLHelper
    { 
       //连数据库
        public static string connString = "server=.;DataBase=StudentManageDB;Uid=sa;Pwd=Sqtj2020";
       //增删改
        public static int Update(string sql)
        {
            SqlConnection conn = new SqlConnection(connString);
            SqlCommand cmd = new SqlCommand(sql, conn);
            try
            {
                conn.Open();
                int result = cmd.ExecuteNonQuery();
                return result;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
        public static object GetSingleResult(string sql)
        {
            SqlConnection conn = new SqlConnection(connString);
            SqlCommand cmd = new SqlCommand(sql, conn);
            try
            {
                conn.Open();
                object result = cmd.ExecuteNonQuery();
                return result;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
        public static SqlDataReader GetReader(string sql)
        {
            SqlConnection conn = new SqlConnection(connString);
            SqlCommand cmd1 = new SqlCommand(sql, conn);
            try
            {
                conn.Open();
                //表示看不懂**********
                return cmd1.ExecuteReader (CommandBehavior.CloseConnection);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            
        }
    }
.
├── HYWJ.suo
├── SMProject
│   ├── SMProject
│   │   ├── App.config
│   │   ├── FrmBalance.cs
│   │   ├── FrmBalance.designer.cs
│   │   ├── FrmBalance.resx
│   │   ├── FrmLogin.cs
│   │   ├── FrmLogin.designer.cs
│   │   ├── FrmLogin.resx
│   │   ├── FrmSaleManage.cs
│   │   ├── FrmSaleManage.designer.cs
│   │   ├── FrmSaleManage.resx
│   │   ├── Program.cs
│   │   ├── Properties
│   │   │   ├── AssemblyInfo.cs
│   │   │   ├── Resources.Designer.cs
│   │   │   ├── Resources.resx
│   │   │   ├── Settings.Designer.cs
│   │   │   └── Settings.settings
│   │   ├── SMProject.csproj
│   │   ├── bin
│   │   │   ├── Debug
│   │   │   │   ├── SMProject.exe
│   │   │   │   ├── SMProject.exe.config
│   │   │   │   ├── SMProject.pdb
│   │   │   │   ├── SMProject.vshost.exe
│   │   │   │   ├── SMProject.vshost.exe.config
│   │   │   │   └── SMProject.vshost.exe.manifest
│   │   │   └── Release
│   │   └── obj
│   │       └── Debug
│   │           ├── DesignTimeResolveAssemblyReferences.cache
│   │           ├── DesignTimeResolveAssemblyReferencesInput.cache
│   │           ├── SMProject.FrmBalance.resources
│   │           ├── SMProject.FrmLogin.resources
│   │           ├── SMProject.FrmSaleManage.resources
│   │           ├── SMProject.Properties.Resources.resources
│   │           ├── SMProject.csproj.FileListAbsolute.txt
│   │           ├── SMProject.csproj.GenerateResource.Cache
│   │           ├── SMProject.csprojResolveAssemblyReference.cache
│   │           ├── SMProject.exe
│   │           ├── SMProject.pdb
│   │           └── TempPE
│   ├── SMProject.sln
│   └── SMProject.v12.suo
└── 找例子网_SMProject.rar
9 directories, 38 files

 
  
					
				
评论