---
title: "项目中几个技术问题的解决方案"
author: "winzenghua"
date: "2009-09-10T14:23:00Z"
tags: []
slug: "untitled"
draft: false
lastmod: "2009-09-10T14:23:00Z"
id: 952898
url: "https://java4gis.iteye.com/blog/952898"
---

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

问题：

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

解决方案：

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

## 2. TreeView加滚动条

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

方法1：

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

方法2：

&lt;asp:Panel ID="PanelScroll" ScrollBars="Auto" runat="server" Height="600px"&gt; &lt;/asp:Panel&gt;

## 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]()

[\\\\Server]()B\\\\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