项目中几个技术问题的解决方案

35 篇文章 0 订阅
10 篇文章 0 订阅

1. sqlserver错误日志过大,占满整个磁盘空间

问题:  

 Sql server errorlog(错误日志)记录了所有错误信息,现在有6个错误日志文件,并且特大,占满了整个磁盘空间。

 

解决方案:

DBCC ERRORLOG,执行一次,切换一次新文件,切换6,6个大文件就消失了。

 

2. TreeView加滚动条

    TreeView放到可以滚动的容器中。

方法1

   <div id="ScrollZone"  style="overflow-y: scroll; overflow-x: hidden; width: 100%; height:600px"></div>

 

方法2

    <asp:Panel ID="PanelScroll" ScrollBars="Auto" runat="server"     Height="600px"> </asp:Panel>

 

3. dbo.SqlQueryNotificationService执行报告权限不够

错误日志消息:

The activated proc [dbo].[SqlQueryNotificationStoredProcedure-db12f828-8b00-4e01-94a0-fb37281108f7] running on queue TpriUserManage.dbo.SqlQueryNotificationService-db12f828-8b00-4e01-94a0-fb37281108f7 output the following:  'Cannot execute as the database principal because the principal "dbo" does not exist, this type of principal cannot be impersonated, or you do not have permission.'

 

解决方案:

This error is caused by the EXECUTE AS infrastructure being unable to impersonate the CDR database owner. Typically this is a result of moving the database between two machines. Change the owner of this database to a valid login. Use one of this to change the TpriUserManage owner:

 

ALTER AUTHORIZATION ON DATABASE::[TpriUserManage] TO [root]

 

4. PI ActiveView编程接口同时访问多个实时数据库

同时传入服务器名和标签名即可,如:

//ServerA//TagA

//ServerB//TagB

5. 执行ExecuteNonQuery()总返回-1

问题:

I'm using .net 2.0 and I have created a stored procedure (sql server DB) which has one insert statement with 2 input parameters. When I execute this stored procedure using ExecuteNonQuery(), it always returning -1. I want to know how many records are effected. I want to know if there is any error. Help appreciated.

 

 

code looks like this:

 

SqlConnection  sqlConn = new SqlConnection();

sqlConn.ConnectionString = "myString...";

 

SqlCommand cmd = new SqlCommand();

cmd.CommandText = "usp_InsertApplicationInfo";

cmd.CommandType = CommandType.StoredProcedure;

 

SqlParameter param1 = cmd.Parameters.Add("@vchrApplicationName", SqlDbType.VarChar);

param1.Direction = ParameterDirection.Input;

 

SqlParameter param2 = cmd.Parameters.Add("@vchrApplicationDescription", SqlDbType.VarChar);

param2.Direction = ParameterDirection.Input;

param1.Value = "prama1";

param2.Value = "test";

cmd.Connection = sqlConn;

sqlConn.Open();

 

int rows = cmd.ExecuteNonQuery();

 

 

解决方案:

below is from VS2005 Documentation:

 

For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For all other types of statements, the return value is -1. If a rollback occurs, the return value is also -1.

 

In your code you call in stored procedure named usp_InsertApplicationInfo in you SqlCommand. So the ExecuteNonQuery() will always return -1 as the sql command is not UPDATE, INSERT, nor DELETE. If you do want to get rows effected by the stored procedure, you can add a OUTPUT parameter to the stored procedure, which return @@ROWCOUNT. For example:

 

alter proc  usp_InsertApplicationInfo

      @ApplicationName varchar(100),

      @ApplicationDescription varchar(max),

      @result int output

as

begin

update myTable set AppDesc=@ApplicationDescription

where AppName=@ApplicationName

select @result=@@rowcount

end

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值