首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏Java架构师必看

    ADO.NET 2.0中的SqlCommand.ExecutePageReader

    在.NET 2.0 PDC或Beta1中,可以看到SqlCommand对象新增了个ExecutePageReader方法,该方法实现了分页读取数据的功能。 ;database=Northwind;Trusted_Connection=yes");         SqlCommand cmd = new SqlCommand(command, conn) 在ADO.NET 2.0 PDC/Beta1中,用SqlCommand.ExecutePageReader进行数据分页:     SqlDataReader GetPageReader(int pageNumber ;database=Northwind;Trusted_Connection=yes");         SqlCommand cmd = new SqlCommand(command, conn)

    57120发布于 2021-03-22
  • 来自专栏米扑专栏

    C#数据库操作的3种典型用法

    sqlCommand = new SqlCommand(); sqlCommand.CommandType = System.Data.CommandType.Text; sqlCommand.Connection = sqlCommand.ExecuteReader(); while(sqlDataReader.Read()) { //Get KeywordID and KeywordName , You sqlCommand = new SqlCommand(); sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = storedProcedureName; sqlConnection.Open(); sqlCommand.ExecuteNonQuery sqlCommand = new SqlCommand(); sqlCommand.CommandType = System.Data.CommandType.Text; sqlCommand.Connection

    81130发布于 2019-02-19
  • 来自专栏centosDai

    CA3001:查看 SQL 注入漏洞的代码

    sqlCommand = new SqlCommand() { CommandText = "SELECT ProductId As SqlCommand = New SqlCommand With {.CommandText = "SELECT ProductId FROM Products WHERE ProductName sqlCommand = new SqlCommand() { CommandText = "SELECT ProductId As SqlCommand = New SqlCommand With {.CommandText = "SELECT ProductId FROM Products WHERE ProductName sqlCommand = new SqlCommand() { CommandText = "sp_GetProductIdFromName

    97900编辑于 2022-02-20
  • 来自专栏艳艳代码杂货店

    C#操作sql通用类 SQLHelper

    命令中用到的参数列表</param> /// <returns>返回一个数值表示此SqlCommand命令执行后影响的行数</returns> public static int ExecuteNonQuery cmd = new SqlCommand(); using (SqlConnection conn = new SqlConnection(connectionString)) { //通过PrePareCommand方法将参数逐个加入到SqlCommand的参数集合中 PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters); int val = cmd.ExecuteNonQuery(); //清空SqlCommand中的参数列表 cmd = new SqlCommand(); PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters

    2.8K20发布于 2021-10-27
  • 来自专栏跟着阿笨一起玩NET

    自定义 SqlHelp

    cmd = new SqlCommand(); 32 CommandBuilder(cmdText, cmd, conn, parameters); 33 cmd = new SqlCommand(); 52 CommandBuilder(cmdText, cmd, conn); 53 SqlDataReader cmd = new SqlCommand(); 94 CommandBuilder(cmdText, cmd, conn); 95 cmd = new SqlCommand(); 141 CommandBuilder(cmdText, cmd, conn); 142 cmd = new SqlCommand(); 239 CommandBuilder(cmdText, cmd, conn); 240

    66520发布于 2018-09-19
  • 来自专栏centosDai

    CA3001:查看 SQL 注入漏洞的代码

    sqlCommand = new SqlCommand() { CommandText = "SELECT ProductId As SqlCommand = New SqlCommand With {.CommandText = "SELECT ProductId FROM Products WHERE ProductName sqlCommand = new SqlCommand() { CommandText = "SELECT ProductId As SqlCommand = New SqlCommand With {.CommandText = "SELECT ProductId FROM Products WHERE ProductName sqlCommand = new SqlCommand() { CommandText = "sp_GetProductIdFromName

    4600编辑于 2022-02-27
  • 来自专栏张善友的专栏

    TransactionScope和Enterprise Libray 3.0 Data Access Application Block

    = "CreditAccount" DbCommand creditCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter = "DebitAccount" DbCommand debitCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(debitCommand = "CreditAccount" DbCommand creditCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter } private void TestCommand2(Database db, int transactionAmount, int destinationAccount) { string sqlCommand = "DebitAccount" DbCommand debitCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(debitCommand

    86380发布于 2018-01-26
  • 来自专栏学习有记

    数据库命令的应用

    .SQL命令 SqlCommand SqlCommand负责完成对数据库的查询、添加、删除和修改等各种操作。 SqlCommand对象的创建 SqlCommand sqlcom = new SqlCommand() sqlCom.Connection = sqlConn; //再将SQL命令的属性Connection指向SQL连接 或 SqlCommand sqlCom = new SqlCommand(命令字符串,连接对象名); SqlCommand对象的三种常用的命令格式 sqlCommand = new SqlCommand(); //声明并实例化SQL命令; sqlCommand.Connection sqlCommand = new SqlCommand(); //声明并实例化SQL命令; sqlCommand.Connection

    2.2K20发布于 2018-07-18
  • 来自专栏全栈程序员必看

    ADO数据库C#中ExecuteReader、ExecuteNonQuery、ExecuteScalar、SqlDataReader、SqlDataAdapter

    { using (SqlConnection conn = new SqlConnection(connectionString)) { SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandType = commandType cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandType = commandType SqlCommand cmd = new SqlCommand("select * from stu", conn); conn.Open(); SqlDataReader cmd = new SqlCommand("select * from stu", conn); conn.Open(); SqlDataReader

    1.3K30编辑于 2022-08-28
  • 来自专栏技术之路

    sqlserver 的事务和c#的事务

    SqlTransaction objtran; 7 objtran = sqlcon.BeginTransaction("Method"); 8 SqlCommand objcmd = new SqlCommand(); 9 objcmd.Connection = sqlcon; 10 objcmd.Transaction _sqlCommand = new SqlCommand(); _sqlCommand.Connection = _strCon; _sqlCommand.Transaction = _sqlTransaction; try { _sqlCommand.CommandText = "insert into PointTcpData (PointTcpData_pointID,PointTcpData_X,PointTcpData_Y

    1.3K90发布于 2018-01-31
  • 来自专栏技术之路

    ADO.NET-DataReader读取数据

    connString); string sql = "select StudentId,StudentName,Gender from Students"; SqlCommand sqlCommand = new SqlCommand(sql,conn); //打开连接 conn.Open(); //执行查询方法 ,返回DataReader对象 SqlDataReader objRader = sqlCommand.ExecuteReader(); //读取数据 StudentId,StudentName,Gender from Students;Select ClassId,ClassName from StudentClass"; SqlCommand sqlCommand = new SqlCommand(sql,conn); //打开连接 conn.Open(); //执行查询方法

    51010编辑于 2024-04-23
  • 来自专栏嘿dotNet

    C# devExpress GridControl 行中行 子行 多级行

    demo,大家不要拘泥于数据 DB db = new DB(); DataSet ds = new System.Data.DataSet(); SqlCommand comm2 = new SqlCommand(sql, db.getSqlConnection()); //db.getSqlConnection() 返回一个sqlConnection 对象 SqlCommand comm3 = new SqlCommand(sql1, db.getSqlConnection()); SqlCommand comm4 = new SqlCommand

    1.5K20发布于 2020-09-11
  • 来自专栏跟着阿笨一起玩NET

    TransactionScope使用说明

    database=northwind"))                     {                         conOne.Open();                         SqlCommand database=pubs"))                     {                         conTwo.Open();                         SqlCommand  command = new SqlCommand("update jobs set job_desc='chen' where job_id='1'", conTwo);                          ;uid=sa;pwd=123;database=pubs");             SqlCommand commandNorthwind = new SqlCommand();              SqlCommand commandPubs = new SqlCommand();             try             {                 conNorthwind.Open

    1.7K10发布于 2018-09-18
  • 来自专栏云计算linux

    C#二十九 数据封装

    SqlCommand myCommand = new SqlCommand(strSql, myConnection); 6. using (SqlCommand cmd = new SqlCommand(StrSql, connection)) 9. using (SqlCommand cmd = new SqlCommand(StrSql, connection)) 15. using (SqlCommand cmd = new SqlCommand(StrSql, connection)) 11. SqlCommand cmd = new SqlCommand(); 27.

    30610编辑于 2024-12-13
  • 来自专栏Java架构师必看

    将Excel文件数据库导入SQL Server

    + "/"" + " -P" + "/"" + "/"" + "/'";     try     {         sqlConnection1.Open();         //SqlCommand  sqlCommand1 = new SqlCommand();         //sqlCommand1.Connection = sqlConnection1;         //sqlCommand1 .CommandText = importSQL;         //sqlCommand1.ExecuteNonQuery();         //MessageBox.Show("import ;         SqlCommand sqlCommand2 = new SqlCommand();         sqlCommand2.Connection = sqlConnection1 ;         sqlCommand2.CommandText = exportSQL;         sqlCommand2.ExecuteNonQuery();         MessageBox.Show

    3.5K30发布于 2021-03-22
  • 来自专栏Danny的专栏

    浅谈ADO.NET中的对象——Connection、Command、DataReader、DataAdapter、DataSet、DataTable

    】     从字面上来看就会理解SqlCommand就是一个命令,当与数据库建立连接之后,就可以用SqlCommand来对数据库进行增删改查、执行存储过程等。     SqlCommand常用的方法有:      ◆ ExecuteNonQuery():返回值为整形,表示对数据库进行增删改后,数据库所影响的行数,也可以直接执行。 更多关于SqlCommand的细节可以参考MSDN:SqlCommand 类 【SqlDataReader】 SqlDataReader主要与SqlCommand结合使用用来快速读取,并且这种读取只能 创建:SqlDataReader只能由SqlCommand对象的ExecuteReader()方法创建。     SqlDataReader通常和SqlCommand一同使用,常用语简单浏览并且耗时较短的数据库操作。        

    1.7K30发布于 2018-09-13
  • 来自专栏DotNet 致知

    使用C#进行数据库增删改查(一)

    SqlComand这个类需要传入sql语句和连接对象,代码如下: SqlCommand command=new SqlCommand("此处是sql语句",connection); 在将具体的增删改查之前 以上代码的运行结果为: 插入,更新,删除: 把这三个放在一块是因为这三个在代码表现层面是一致的,都是调用SqlCommand的ExecuteNonQuery()方法,该方法返回int类型的数据 command = new SqlCommand (sql, connection)) { try { if (parameters ! command = new SqlCommand (sql, connection)) { try { command = new SqlCommand (sql, connection)) { try {

    2K10编辑于 2022-03-29
  • 来自专栏全栈程序员必看

    C#结合数据库开发通讯录管理系统

    com = new SqlCommand(sqlcom, con); con.Open(); SqlDataReader reader com2 = new SqlCommand(sqlcom2, con); int eq=com2.ExecuteNonQuery(); if(eq! com = new SqlCommand(sqlcom, con); con.Open(); int eq = com.ExecuteNonQuery( com = new SqlCommand(sqlcom, con); con.Open(); int eq=com.ExecuteNonQuery(); com = new SqlCommand(sqlcom, con); con.Open(); int eq = com.ExecuteNonQuery(

    2.8K20编辑于 2022-07-22
  • 来自专栏全栈程序员必看

    TransactionScope使用说明

    只要任意一个 SqlCommand 对象引发异常,程序流控制就会跳出 TransactionScope 的 using 语句块,随后,TransactionScope 将自行释放并回滚该事务。 cmd= new SqlCommand(sqlUpdate, cn2005); cn2005.Open(); cmd.ExecuteNonQuery(); } using (SqlConnection cn2005= new SqlConnection(anotherSql2005)) { SqlCommand cmd= new SqlCommand(sqlDelete, cn2005); cn2005 cmd= new SqlCommand(updateSql1, cn2005); cn2005.Open(); cmd.ExecuteNonQuery(); } tsCope.Complete(); cmd= new SqlCommand(updateSql2, cn2005); cn2005.Open(); cmd.ExecuteNonQuery(); } ts.Complete(); } }

    99910编辑于 2022-09-09
  • 来自专栏后端/图像融合/机器学习/爬虫

    C#实现ADO连接sql server数据库

    command = new SqlCommand(sql, con); SqlDataReader reader = command.ExecuteReader(); command = new SqlCommand(sql, con); int a = command.ExecuteNonQuery(); con.Close "update Table_1 set name='" + user.Name+"' where id="+user.Id; con.Open(); SqlCommand command = new SqlCommand(sql, con); int a = command.ExecuteNonQuery(); con.Close command = new SqlCommand(sql, con); SqlDataReader reader = command.ExecuteReader();

    74010编辑于 2024-06-19
领券