C#如何写DBHelper 类(数据库连接和操作)

DBHelper类使用 1.先在Web.config 文件中加入要连接的数据库 在<configuration>里面加入 <connectionStrings > <add name="logisDb" connectionString="Data Source=.;Initial Catalog=logis;Integrated Security=True"/&... 阅读详情

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

namespace UseAdo
{
    public class DBHelper
    {

    //连接字符串
      public static readonly string ConnectionString = ConfigurationManager.ConnectionStrings["SQLConn"].ToString();

//非查询操作

        public static int ExecuteNonQuery(string commandText, CommandType commandType, params SqlParameter[] param)
        {
            int count = 0;
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = con;
                cmd.CommandText = commandText;
                cmd.CommandType = commandType;
                if (param != null)
                {
&nb

C#可视化编程技术第三章:DBHelper类(内含思路、代码、注释) DBHelper类: 阅读详情

相关推荐

C# 随记2 DBHelper创建 数据库连接、增删改查封装

public static OleDbDataReader GetReader(string str) // 因为 非断开式访问 ,返回的是一个数据访问对象!//非断开开式数据访问,,不可关闭连接!//执行 ADO.net相关函数操作 ,无非 增删改查,,以及聚合函数 的执行,,可以全部封装到此,吧所有方法封装到此。//Adapter,将数据库和数据集,关联到一起。//因为是断开式数据访问,所以数据填充完毕后,可以关闭连接。// 查询 1、非断开式访问 2、断开式访问。

m0_65344060的博客 1038

C#中使用DbHelper连接SqlServer数据库

场景 C#的窗体应用中,经常要连接数据库进行相应的操作。 进行简单的数据库连接测试。 实现 新建窗体应用,在工具箱中拖拽一个Button按钮。 右击项目名-添加-类 DBHelper类,连接数据库工具类。 using System; using System.Collections.Generic; using System.Linq; using System.Text...

BADAO_LIUMANG_QIZHI的博客 2441

C#通用数据库连接类DBHelper的设计与实现

数据库操作是构建现代应用程序不可或缺的一部分,尤其在C#开发环境中,它提供了强大的数据处理能力。C#与数据库之间的交互主要依赖于ADO.NET框架,它提供了一组丰富的对象,用于执行命令、管理事务、处理结果集以及优化数据库连接。在进入更深入的讨论之前,先概括一下C#数据库操作的关键点:首先,构建可靠的连接至数据库,这是任何数据库操作的前提;其次,执行SQL命令来查询或修改数据,确保操作的准确性和效率;进一步,掌握事务处理机制以确保数据的一致性;然后,利用参数化查询来提高安全性和查询性能;

weixin_42602726的博客 586

C#根据模型动态生成SQL和DBHelper

根据模型自动生成SQL语句,加快开发的速度,方便理解EF的原理,代码简单易懂。还包含DBHelper。

IFIX往Mysql数据库同步数据方法

通过IFix数据库向Mysql数据库同步数据

仙人掌 1596

基于ARDUINIO的5路红外循迹小车

基于ARDUINIO的5路红外循迹小车 新手抄袭了很多大神的代码。这里表示感谢。 #define STOP 0 #define FORWARD 1 #define BACKWARD 2 #define STURNLEFT 3 #define STURNRIGHT 4 #define TURNLEFT 5 #define TURNRIGHT 6 #define TURNRIGHT90 7 #define TURNLEFT90 8 int leftA_PIN = A0; int

weixin_48214416的博客 4381

AutoLISP 学习 (一)

AutoLISP基本语法结构、语法 以括号组成表达式,左右括号一定要成对,单、双引号也要成对,例如: (defun c:hello() (princ "\nHello world!") (prin1) ) 表达式格式:(函数名 操作数 操作数 …),例如: (setq p1 (list 0 0)) (setq p2 (list 10 10)) (setq p3 (list 20 20)) ;;; CAD中画直线,经过p1 p2 p3 (command "LINE" p1 p2 p3 ""

m0_54575622的博客 2123

YOLO系列专栏(十二):YOLO26行业落地实战(三):无人机航拍场景——户外巡检(机载边缘计算+YOLO26)

无人机航拍巡检场景,面临机载设备算力/显存有限、高空航拍目标小、户外环境复杂(风力、光线变化)、图像抖动等问题,对模型的轻量化、实时性、小目标检测能力要求极高。YOLO26相比传统模型,在该场景中具备三大核心优势:✅ 极致轻量化:INT8量化+模型剪枝后,模型体积可压缩至5MB以内,显存占用控制在512MB以内,适配Jetson Xavier NX等机载边缘计算设备;✅ 小目标检测能力强:优化检测头与锚框配置,可精准识别高空航拍中的小尺寸目标(如线路断股、绝缘子裂纹),检测准确率高;

qq_36130719的博客 261

图神经网络与大模型融合的理论综述:架构、机制与未来方向

然而,它们普遍缺乏对图结构数据的原生支持,无法直接处理边、节点之间的拓扑关系,这限制了其在关系密集型任务中的表现 [23]。2020年发布的BERT [16] 开启了自监督预训练时代,而2021年后,T5 [17]、PaLM [18]、LLaMA [19] 等模型相继推出,参数规模突破千亿级,展现出惊人的上下文学习(In-context Learning)与链式推理(Chain-of-Thought)能力 [20]。例如,将医学影像作为图节点,结合病理报告文本,实现更精准的疾病诊断 [58]。

andeyeluguo的博客 295

[STC32G144K246入门第六步]DAC驱动

本文摘要介绍了STC32G144微控制器内置的12位DAC模块特性与应用。该芯片集成双通道独立DAC,需通过内部运放缓冲后从P0.7/P5.0引脚输出,支持音频处理、波形生成等应用场景。重点阐述了DAC的R-2R梯形网络工作原理、关键性能指标(12位分辨率、转换速度等)及编程配置方法,包括频率设置、寄存器操作和运放引脚配置。文中还提供了32点正弦波表示例和初始化代码,强调参考电压稳定性对输出精度的重要影响。

sinat_58149788的博客 141

【图像拼接(Image Stitching)】关于【图像拼接论文精读】专栏的相关说明,包含专栏使用方法、阅读顺序、创新思路、文章汇总、源码汇总、数据集汇总等。总之,【图像拼接论文相关】看这一篇就够了

为什么会有这篇文章?因为专栏简介里写不下太多东西,只能通过这篇文章和大家交流,算是一个专栏阅读指南吧。说点心里话本来吧,我只想用优快云来记录自己学习【图像拼接】领域论文的过程,对每篇文章有个细致的理解,方便自己反复查阅。设置为付费也是因为涉及论文和本人其他项目需要,防止查重和其他问题,所以价格最开始设置的是专栏付费价格里最高的。起初,确实没有人看,一切也都平淡地度过着。

主要更新底层视觉(去噪、超分等)相关的科研内容,形式为【论文精读】+【论文复现】 4万+

译码器Multisim电路仿真汇总——硬件工程师笔记

本文详细介绍了74LS139D和74LS138D两种TTL译码器的功能特点及应用。74LS139D是2线-4线译码器,具有低电平有效输出和使能控制功能,常用于地址译码和数据分配。74LS138D是3线-8线译码器,通过3位输入实现8路输出控制,广泛应用于微处理器系统。文中提供了两种芯片的引脚说明、真值表和典型应用电路,并附有硬件工程师笔试面试相关资源链接。这些基础知识对数字电路设计和硬件工程师面试准备具有重要参考价值。

XU157303764的博客 1266

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

上一篇: 冒泡排序解决实际问题
下一篇: 游标 Cursor
YoungHeartOldFace
博客等级 码龄14年 7粉丝 28原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值