SQL间断式连接
2011-12-01 11:21
197 查看
sql.cs using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Data.SqlClient; namespace WindowsApplication1 { class sql { private static SqlConnection conn = new SqlConnection("workstation id=localhost;Integrated Security=SSPI;database=test"); private static SqlCommand cmd = new SqlCommand(); private static SqlDataAdapter da = new SqlDataAdapter(); public static DataTable getdata(string cmdtext) { da.SelectCommand = cmd; da.SelectCommand.Connection = conn; da.SelectCommand.CommandText = cmdtext; conn.Open(); da.SelectCommand.ExecuteNonQuery(); conn.Close(); DataSet ds = new DataSet(); da.Fill(ds); return ds.Tables[0]; } public static int exec(string cmdtext) { cmd.CommandText = cmdtext; cmd.Connection = conn; conn.Open(); int i = cmd.ExecuteNonQuery(); conn.Close(); return i; } } }
相关文章推荐
- 让SQL Server Management Studio直接连接数据库
- SQL 之 外连接
- SQL 联接--->内联接 (自然连接 join..on)
- 【php配置】用php5.6.15连接sqlserver2012加入驱动后看不到sqlsrv扩展
- PL/SQL Developer如何连接64位的Oracle图解
- 利用Oracle SQL Developer创建database link数据库连接
- 深入理解SQL的四种连接-左外连接、右外连接、内连接、全连接
- SQL: 外连接查询.
- sqlplus连接远程数据库
- 【SQL Server Hardware】Windows Server下启用SQL Server 2008的远程连接
- sql 内连接和外连接
- VS环境下 Ibatis .Net 连接sqlserver 2005 碰到的问题 Unable to open connection to "Microsoft SQL Server, provider V2.0.0.0 in framework .NET V2.0".
- 增加表连接来优化SQL
- SQL中常见的几种连接
- 免安装PL/SQL无法连接本地ORACLE数据库解决方法
- PL/SQL 工具 ORA-12514,监听程序当前无法识别连接描述符
- 安装sql 2005 express 后,并使用navicat远程连接数据库。
- win 下python2.7 pymssql连接ms sqlserver 2000
- windows7 连接SQL 1433端口被占用 到主机 的 TCP/IP 连接失败
- sqlplus连接远程数据库