易截截图软件、单文件、免安装、纯绿色、仅160KB

C#连接SQL Server 2005 Express的字符串

C#连接SQL Server的SqlConnection的字符串,许多都是不能连接的。现在给一个能连接的:
using System.Data.SqlClient;
public class sqlServerConnection {
//
public static void Main() {
//下面就是标准的连接,注意SERVER是我的计算机名。SQLEXPRESS是数据库实例。SSPI表示使用Windows登陆的帐户。master是要连接的数据库。
//
string cstr = "server=SERVER\\SQLEXPRESS;Initial Catalog=master;Integrated Security=SSPI";
//
try {
//
using (SqlConnection con = new SqlConnection(cstr)) {
con.Open();
System.Console.WriteLine("ServerVersion:{0}",con.ServerVersion);
System.Console.WriteLine("State:{0}",con.State);
}
//
}
catch (System.Exception sqle) {
System.Console.WriteLine(sqle.Message);
}
//
}
//
}
/*
程序的输出:
ServerVersion:09.00.3042
State:Open
*/
//不使用远程连接的时候应该把连接字符串改为:
"Server=localhost\\SQLExpress;Integrated Security=SSPI"
//也可以指定默认的数据库,例如,指定默认数据库是"master"就应该写为:
"Server=localhost\\SQLExpress;Initial Catalog=master;Integrated Security=SSPI"
或者:"Server=localhost\\SQLExpress;Initial Catalog=master;Uid=sa;Pwd=sa"
B/S模式连接数据库:
string sql="Source=服务器Ip;database=数据库名称;UID=sa;Password=sasa;";
C/S模式连接数据库:
string sql="Data Source=服务器Ip;Initial Catalog=数据库名称;User ID=sa;password=sa";
连接SQL Server 2005 Express的问题
2010-01-15 13:33
错误信息:
“在建立与服务器的连接时出错。在连接到 SQL Server 2005 时,在默认的设置下 SQL Server 不允许进行远程连接可能会导致此失败。 (provider: 命名管道提供程序, error: 40 - 无法打开到 SQL Server 的连接)”
解决方案:
1.安装一个SQL Server Management Studio Express。微软官方有下载,baidu,google里面都能查到。
2.安装完成后,开始菜单里找到Microsoft SQL Server 2005--配置工具--SQL Server 外围应用配置器--服务和连接的外围应用配置器:
打开MSSQLSERVER节点下的Database Engine 节点,选择"远程连接",再选择"同时使用TCP/IP和Named pipes",确定后重启数据库服务。
3.用默认Windows身份验证模式登录SQL Server Management Studio Express,选择左边列表里面


相关文档:

SQL查询效率 100w数据查询只要1秒

机器情况
p4: 2.4
内存: 1 G
os: windows 2003
数据库: ms sql server 2000
目的: 查询性能测试,比较两种查询的性能
SQL查询效率 step by step
-- setp 1.
-- 建表
create table t_userinfo
(
userid int identity(1,1) primary key nonclustered,
nick&nbs ......

Linq to sql增删改查

private void button2_Click(object sender, EventArgs e)//增
{
try
{
Customers ct = new Customers();
ct.CustomerID = "test";
ct.CompanyName = "test";
NorthwindDataContext nc = new NorthwindDataContex ......

sql手工注入

SQL手工注入大全
2006年08月11日 星期五 21:00
比方说在查询id是50的数据时,如果用户传近来的参数是50 and 1=1,如果没有设置过滤的话,可以直接查出来,SQL 注入一般在ASP程序中遇到最多,
看看下面的
1.判断是否有注入
;and 1=1
;and 1=2
2.初步判断是否是mssql
;and user>0
3.判断数据库系统
;and ......

PL/SQL 学习笔记1

PL/SQL 不具备输入输出的能力
但是可以依靠环境来执行数值的输入输出给PL/SQL 块
SQLPLUS 环境用substitution variables 和 host(bind) variable 来传入数值给PL/SQL块
substitution variable: such as a preceding ampersand  &a
host(bind) variable : such as a  preceding colon :x
替 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号