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

    SqlConnection.ConnectionString 属性

    SqlConnection 属性只返回那些包含在 ConnectionString 中的设置。 若要连接到本地机器,请将服务器指定为“(local)”。(必须始终指定一个服务器。) Pooling ‘true’ 当该值为 true 时,系统将从相应池中提取 SQLConnection 对象,或在必要时创建该对象并将其添加到相应池中。 示例 [Visual Basic, C#] 下面的示例创建一个 SqlConnection并设置它的一些属性。 myConnection.Open() End Sub 'CreateSqlConnection [C#] public void CreateSqlConnection() { SqlConnection myConnection = new SqlConnection(); myConnection.ConnectionString = "Persist Security Info=False

    1.5K10编辑于 2022-09-14
  • 来自专栏学习有记

    数据库连接对象的使用

    连接字符串 1、连接字符串的写法 在字符串变量中,描述连接字符串所需的服务器地址、数据库名称、集成安全性(即是否使用Windows验证) sqlConnection.ConnectionString = 实例化“连接对象”,并打开连接 SqlConnection sqlConnection = new SqlConnection(); //声明并实例化SQL连接; sqlConnection.ConnectionString 服务器地址:" + sqlConnection.DataSource + "\n服务器版本:" + sqlConnection.ServerVersion sqlConnection = new SqlConnection(); sqlConnection.ConnectionString = sqlConnectionStringBuilder.ConnectionString sqlConnection = new SqlConnection();

    1.9K20发布于 2018-07-18
  • 来自专栏历史专栏

    【愚公系列】2023年02月 .NET CORE工具案例-Dapper-Extensions的使用

    cn = new SqlConnection(_connectionString)) { cn.Open(); Person p = new Person { Active = true cn = new SqlConnection(_connectionString)) { cn.Open(); int personId = 1; Person person = cn.Get<Person>(personId); cn.Close(); } 2.3 删除记录 using (SqlConnection cn = new SqlConnection(_ cn = new SqlConnection(_connectionString)) { cn.Open(); int personId = 1; Person person cn = new SqlConnection(_connectionString)) { cn.Open(); var predicate = Predicates.Field<Person

    1.5K30编辑于 2023-03-16
  • 来自专栏跟着阿笨一起玩NET

    自定义 SqlHelp

    conn = new SqlConnection(connString); 31 SqlCommand cmd = new SqlCommand(); 32 conn = new SqlConnection(connString); 51 SqlCommand cmd = new SqlCommand(); 52 conn = new SqlConnection(connString)) 71 { 72 SqlCommand cmd = new SqlCommand conn = new SqlConnection(connString)) 163 { 164 SqlDataAdapter da = new conn = new SqlConnection(connString)) 188 { 189 SqlDataAdapter da = new

    65020发布于 2018-09-19
  • 来自专栏Java架构师必看

    将Excel文件数据库导入SQL Server

    SELECT classID, classDate, classPlace, classTeacher, classTitle, durativeDate FROM gch_Class_Info",sqlConnection1 ;     sqlConnection1 = new SqlConnection();     sqlConnection1.ConnectionString = "server=(local);integrated ;         SqlCommand sqlCommand2 = new SqlCommand();         sqlCommand2.Connection = sqlConnection1 ;     }     catch(Exception ex)     {         MessageBox.Show(ex.ToString());     } } if(sqlConnection1 =null) {     sqlConnection1.Close();     sqlConnection1 = null; } //方案三: 通过到入Excel的VBA dll,通过VBA接口获取

    3.5K30发布于 2021-03-22
  • 来自专栏学习有记

    数据库命令的应用

    private void btn_LogIn_Click(object sender, EventArgs e) { SqlConnection sqlConnection = new SqlConnection (); //声明并实例化SQL连接; sqlConnection.ConnectionString = "Server= ; sqlConnection.Close(); //关闭SQL连接; #### SqlConnection sqlConnection = new SqlConnection(); //声明并实例化SQL连接; sqlConnection.ConnectionString = "Server=(local);Database=EduBaseDemo;Integrated Security

    2.2K20发布于 2018-07-18
  • 来自专栏老K博客

    使用 C# 和 SQL Server 实现数据库的实时数据同步

    sourceConnection = new SqlConnection(sourceConnectionString)) { sourceConnection = new SqlConnection(sourceConnectionString)) { sourceConnection.Open sourceConnection = new SqlConnection(sourceConnectionString)) using (SqlConnection targetConnection = new SqlConnection(targetConnectionString)) { sourceConnection.Open(); sourceConnection = new SqlConnection(sourceConnectionString)) using (SqlConnection targetConnection

    1.7K10编辑于 2024-11-05
  • 来自专栏逸鹏说道

    Dapper逆天入门~强类型,动态类型,多映射,多返回值,增删改查+存储过程案例演示

    conn = new SqlConnection(connStr)) { conn.Open(); //无参查询 conn = new SqlConnection(connStr)) { string sqlStr = @"select A.Id,A.Title,S.SeoKeywords from Article conn = new SqlConnection(connStr)) { string sqlStr = @"select Id,Title,Author from Article where conn = new SqlConnection(connStr)) { conn.Open(); int count = conn.Execute("usp_insertArticle conn = new SqlConnection(connStr)) { conn.Open(); int count = conn.Execute("usp_updateArticle

    1.4K70发布于 2018-04-10
  • 来自专栏米扑专栏

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

    sqlConnection = new SqlConnection(sqlConnectionCommand); SqlCommand sqlCommand = new SqlCommand(); = sqlSelectCommand; sqlConnection.Open(); SqlDataReader sqlDataReader = sqlCommand.ExecuteReader() sqlConnection = new SqlConnection(sqlConnectionCommand); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Dispose(); sqlConnection.Close(); } ==================================================== ===== public void UseSqlDataSet() { SqlConnection sqlConnection = new SqlConnection(sqlConnectionCommand

    80630发布于 2019-02-19
  • 来自专栏云计算linux

    宿舍系统增加学生信息

    sqlConnection1 = null; public AddAccident() { InitializeComponent(); this.sqlConnection1 = new SqlConnection(DormManageSystem.database.sqlConnection.connection); , "提示"); else { sqlConnection1.Open(); where dormid ='" + dormid.Text.Trim() + "'"; SqlCommand cmd = new SqlCommand(sql, sqlConnection1 , "提示"); } sqlConnection1.Close(); }

    30310编辑于 2024-12-22
  • 来自专栏Danny的专栏

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

    ;database=DataBaseName;uid=sa;pwd=123456"; //定义数据库连接字符串 SqlConnection conn = new SqlConnection(strConn 需要注意的是:一个SqlConnection连接下只允许打开一个SqlDataReader,此时这个SqlConnection对象只为这一个SqlDataReader服务,如果还想再打开一个SqlDataReader ,则必须先讲前面那个关闭(当然也可以再创建一个SqlConnection对象,了解一下多线程就会明白)。 SqlConnection对象conn,节省系统资源。     举例如下: public static DataTable SelectAll() { SqlConnection conn=new SqlConnection("server=

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

    C#二十九 数据封装

    SqlConnection myConnection = new SqlConnection(conString ); 4. using (SqlConnection connection = new SqlConnection(conString)) 7. { 8. SqlConnection myConnection = new SqlConnection(conString); 5. using (SqlConnection connection = new SqlConnection(conString)) 19. { 20. SqlConnection myConnection = new SqlConnection(conString); 4.

    26710编辑于 2024-12-13
  • 来自专栏全栈程序员必看

    DropDownList1_SelectedIndexChanged-的使用

    ;database=mag_Web;User ID=sa;password=;" 'Dim myconn As SqlConnection 'myconn = New SqlConnection(connstr ) 'myconn = mydb.GetSqlconn() Dim myconn As SqlConnection = myconnection.GetSqlconn myconn.Open() Dim ;database=mag_Web;User ID=sa;password=;" Dim myconn As SqlConnection = myconnection.GetSqlconn 'myconn ;database=mag_Web;User ID=sa;password=;" Dim myconn As SqlConnection = myconnection.GetSqlconn 'myconn = New SqlConnection(connstr) 'myconn = mydb.GetSqlconn() myconn.Open() Dim mycommand As New SqlCommand

    38920编辑于 2022-09-09
  • 来自专栏米扑专栏

    C#连接数据库SQL(2005)

    首先来总结一下进行数据库编程的全过程,这里用的是SQL SERVER (1) 建立SqlConnection对象以连接数据库 SqlConnection mysqlconnection=new SqlConnection("Server=localhost; database=yourdatabase;uid=sa;pwd=sa"); (2) 建立SqlCommand对象 SqlCommand  设置SqlCommand对象的CommandText属性 mysqlcommand.CommandText="SELECT * FROM youydatabasetablename"; (4) 打开SqlConnection (9) 关闭SqlConnection对象 mysqlconnection.Close(); 下面把过程呈现出来. 1、在我的程序中用的是SQL,所以在程序头前加上 using System.Data.SqlClient try { mysqlconnection = new SqlConnection("server=localhost; Integrated Security=True;Database=myfriends

    1.6K30发布于 2019-02-19
  • 来自专栏云计算linux

    Asp.Net就业课之案例实践第二次课

    ;database=MyDb;uid=asp;pwd=asp"; SqlConnection conn = new SqlConnection(str); ;database=mydb;uid=asp;pwd=asp"; SqlConnection conn = new SqlConnection(str); ;database=mydb;uid=asp;pwd=asp"; SqlConnection conn = new SqlConnection(str); ;database=mydb;uid=asp;pwd=asp"; SqlConnection conn = new SqlConnection(str); ;database=mydb;uid=asp;pwd=asp"; SqlConnection conn = new SqlConnection(str);

    19100编辑于 2024-12-13
  • 来自专栏全栈程序员必看

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

    conn = new SqlConnection(connectionString)) { SqlCommand cmd = new SqlCommand(); conn = new SqlConnection(connectionString)) { SqlCommand cmd = new SqlCommand( conn = new SqlConnection(connectionString); SqlDataReader dr = null; SqlCommand cmd conn = new SqlConnection(connectionString)) { SqlDataAdapter da = new SqlDataAdapter conn = new SqlConnection(str); SqlCommand cmd = new SqlCommand("select * from stu", conn

    1.3K30编辑于 2022-08-28
  • 来自专栏全栈程序员必看

    TransactionScope使用说明

    由于这段代码使用了 using 语句,所以 SqlConnection 对象和 TransactionScope 对象都将被自动调用Dispose()释放。 //创建TransactionScope using (TransactionScope tsCope= new TransactionScope()) { using (SqlConnection cn2005= new SqlConnection(someSql2005)) { SqlCommand cmd= new SqlCommand(sqlUpdate, cn2005); cn2005 .Open(); cmd.ExecuteNonQuery(); } using (SqlConnection cn2005= new SqlConnection(anotherSql2005)) cn2005= new SqlConnection(cnString) { SqlCommand cmd= new SqlCommand(updateSql1, cn2005); cn2005.Open

    98110编辑于 2022-09-09
  • 来自专栏Vincent-yuan

    Dapper学习(四)之Dapper Plus的大数据量的操作

    使用Bulk插入单个实体 DapperPlusManager.Entity<Customer>().Table("Customers"); using (var connection = new SqlConnection Many :插入多个实体 DapperPlusManager.Entity<Customer>().Table("Customers"); using (var connection = new SqlConnection Update Many DapperPlusManager.Entity<Customer>().Table("Customers"); using (var connection = new SqlConnection Merge Single DapperPlusManager.Entity<Customer>().Table("Customers"); using (var connection = new SqlConnection 4.2 Merge Many DapperPlusManager.Entity<Customer>().Table("Customers"); using (var connection = new SqlConnection

    2.4K10发布于 2019-09-29
  • 来自专栏centosDai

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

    connection = new SqlConnection(ConnectionString)) { SqlCommand sqlCommand = New SqlConnection(ConnectionString) Dim sqlCommand As SqlCommand = New SqlCommand connection = new SqlConnection(ConnectionString)) { SqlCommand sqlCommand = New SqlConnection(ConnectionString) Dim sqlCommand As SqlCommand = New SqlCommand = New SqlConnection(ConnectionString) Dim sqlCommand As SqlCommand = New SqlCommand

    97300编辑于 2022-02-20
  • 来自专栏李蔚蓬的专栏

    ASP.NET | 从零到一实战分析对后台数据库增加数据、模糊查找、精确查找并展示

    public common() { // // TODO: 在此处添加构造函数逻辑 // } public static SqlConnection { string connstr = ConfigurationManager.ConnectionStrings["connstr"].ToString(); SqlConnection myconn = new SqlConnection(connstr); return myconn; } } 回来default窗口,双击设计界面里边入库按钮,开始编写逻辑: myconn = new SqlConnection(connstr); myconn.Open(); string cmdstr = @"select * from 分别添加点击逻辑即可: protected void jqFind_Button_Click(object sender, EventArgs e) { SqlConnection

    1.1K40发布于 2019-02-25
领券