
打开”Microsoft SQL Server Management Studio“ 直接用Windows 用户连接进入,再在“安全性”中的“登录名”内的“新建登录名”,你就对应的添好“确定”就可以了。
再在你对应的“数据库”里“安全性”用户,把你建的用户添加进去。
关键地方,查看“服务器 属性”在 “安全性”选上 “SQL Server 和 Windows 身份验证模式”点 “确定”系统会提示你重新启动SQL Server 你“停止”重启一下就配好了。
接着看C#连接SQL Server2005的代码语句:
strcon = strcon + @"Data Source=" + strcons[0]
strcon = strcon + "," + strcons[2] + ""
strcon = strcon + "Network Library=" + strcons[1] + ""
strcon = strcon + "Initial Catalog=" + strcons[3] + ""
strcon = strcon + "User ID=" + strcons[4] + ""
strcon = strcon + "Password=" + strcons[5] + ""
strcon = strcon + "Persist Security Info=True"
strcons[0] 服务器名称,一般添机器的IP
strcons[1]协议DBMSSOCN(为tcp/ip协议)
strcons[2]]端口号,一般为1433
strcons[3] 数据库名
strcons[4] 用户名
strcons[5]密码
端口号也要配置一下:
在控制面板里的服务和应用程序中的SQL Server配置管理中的SQL Server 2005网络配置内的SQL
Server2005的协议TCP/IP默认为已禁用,在它的属性设置它的端口号为1433 “确定” 启动。
\--1--\select * from 仓库 where 面积>350
\--2--\
select 仓库号,avg(工资) from 职工
\--3--\
select 姓名,工资 into zgxx from 职工
\--4--\
select 姓名 from 职工 where 姓名 like('张%')
\--5--\
select 姓名,工资 from 职工 where 仓库号='WH1'
\--6--\
select * from 订单 where 订购日期 like('2008%06%')
\--7--\
select * from 订单 where 职工号='E1'
\--8--\
select 供应商号,sum(订单数量) as 合计订单数 from 订单 group by 供应商号
\--9--\
select 职工号,sum(订单数量) as 合计订单数 from 订单 group by 职工号
\--10--\
select * from 供应商 where 供应商名 like ('%北京%')
\--11--\
update 职工 set 仓库号='WH4' where 姓名='孙小空'
\--12--\
select sum(面积) 面积总和 from 仓库
\--13--\
select count(职工号) as 人数,仓库号 from 职工 group by 仓库号
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)