1。排错
和sql server较了一天的劲,只写了两个简单的存储过程。当然智商虽然不高还没低到这个份上。大半天都是花费在排错上了。
System.Data.SqlClient.SqlException: SQL Server 不存在或访问被拒绝。 at System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) at System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) at System.Data.SqlClient.SqlConnection.Open() at _20060409.WebForm1.test() in d:\work files\20060409\webform1.aspx.cs:line 52
冷不丁报了这个错,这个就是从程序里连不上。在服务中除了MSSQLserverADHelper以外所有的服务都打开了还是不行;名称正确、无别名、没起实例名称;端口号服务器端和客户端都是1433。为了找出问题只好上网查查结果发现连上网线后这个毛病就没了。晕,看来是少打了什么补丁。
2。写循环
首先需求是这样的我手里现在有两张表,rights和roles。
表结构如下:
rights
-------------------
rightid int
right varchar(20)
==========
roles
-------------------
roleid int
roletype int
role varchar(20)
rightid int
在我的role表里有一个角色admin。admin拥有right表中的所有权限,但是有四个字段,要是用手写完我这个速度,加上这个数量我看也就算了。省了手上的力气就要费脑子。
在查询分析器里写了半天,总算是吭哧出来了。
首先使用truncate table把role原来的失败信息清掉,听说会比delete快一点,只不过数量少看不出明显效果。
然后建立一个临时的用于填充的存储过程。
create procedure TempFill
declare mycursor cursor for
select rightid from rights--这两个是一句,定义游标,然后从rights中取一个rightid给游标
open mycursor
declare @rightid int--定义一个变量
fetch mycursor into @rightid--把mycursor当前的值给@rightid
while @@fetch_status=0
begin
insert into rolestable (roletype,role,rightid)values(1,'admin',@rightid)
fetch mycursor into @rightid
end
close mycursor
deallocate mycursor
这样就写完了。
execute TempFill 再执行他一下。
和sql server较了一天的劲,只写了两个简单的存储过程。当然智商虽然不高还没低到这个份上。大半天都是花费在排错上了。
System.Data.SqlClient.SqlException: SQL Server 不存在或访问被拒绝。 at System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) at System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) at System.Data.SqlClient.SqlConnection.Open() at _20060409.WebForm1.test() in d:\work files\20060409\webform1.aspx.cs:line 52
冷不丁报了这个错,这个就是从程序里连不上。在服务中除了MSSQLserverADHelper以外所有的服务都打开了还是不行;名称正确、无别名、没起实例名称;端口号服务器端和客户端都是1433。为了找出问题只好上网查查结果发现连上网线后这个毛病就没了。晕,看来是少打了什么补丁。
2。写循环
首先需求是这样的我手里现在有两张表,rights和roles。
表结构如下:
rights
-------------------
rightid int
right varchar(20)
==========
roles
-------------------
roleid int
roletype int
role varchar(20)
rightid int
在我的role表里有一个角色admin。admin拥有right表中的所有权限,但是有四个字段,要是用手写完我这个速度,加上这个数量我看也就算了。省了手上的力气就要费脑子。
在查询分析器里写了半天,总算是吭哧出来了。
首先使用truncate table把role原来的失败信息清掉,听说会比delete快一点,只不过数量少看不出明显效果。
然后建立一个临时的用于填充的存储过程。
create procedure TempFill
declare mycursor cursor for
select rightid from rights--这两个是一句,定义游标,然后从rights中取一个rightid给游标
open mycursor
declare @rightid int--定义一个变量
fetch mycursor into @rightid--把mycursor当前的值给@rightid
while @@fetch_status=0
begin
insert into rolestable (roletype,role,rightid)values(1,'admin',@rightid)
fetch mycursor into @rightid
end
close mycursor
deallocate mycursor
这样就写完了。
execute TempFill 再执行他一下。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22392018/viewspace-742250/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/22392018/viewspace-742250/